I want to delete all lines in a file that contain one pattern, but not another.
For example, if I have this file:
hello people foo
hello world bar
hello something
blah blah blah
I want to delete all lines that contain hello
, but not world
, so that my file looks like this:
hello world bar
blah blah blah
I tried the following:
sed -n '/hello/p' file | sed -i '/world/!d'
But I get the error message -i may not be used with stdin