Grep get everything except matching
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
isHowever 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?
01 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.