Looks like you are trying to remove foo from the file. Maybe this will work for you:
$ sed 's/foo//g' ./file bar bar What you are telling grep is:
- Print
foofor each instance, and - Print lines that don't have a
foo
What you meant to tell grep was:
- Print lines that don't match
foo, or the parts of lines that don't include afoo
That can be reduced to:
- Print every line, but remove
foofrom them
The two statements are pretty different. I think sed is a good solution for you and describes the reduced statement pretty well.