Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Grep get everything except matching

Writer Matthew Barrera

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?

0

1 Answer

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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