Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Lets say I have a text file that says:

Hello my name is agz.
I am asking a question that is important.

If i type: grep -v "is" /path/to/file, I should get no output because both lines have "is".

If i type: grep -o "is" /path/to/file, i should get:

is
is

However I want to get:

Hello my name agz.
I am asking a question that important.

(just missing the is) Is there a way to achieve this using grep and minimal regex?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

grep isn't the right tool for this job. sed is.

$ sed 's|is||g' test.txt
Hello my name  agz.
I am asking a question that  important.

$ sed 's|is ||g' test.txt
Hello my name agz.
I am asking a question that important.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.