0

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?

9

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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