How can I use grep to display lines WITHOUT either of two specific strings?
To remove lines that contain either string, specifically with grep:
In one command, per jordanm's comment:
grep -Ev 'success|ok$'
or:
grep -ve success -e 'ok$'
or:
grep -v 'success ok$'
In two commands:
grep -v success file | grep -v 'ok$'
Example:
$ cat file
success something else
success ok
just something else
$ grep -Ev 'success|ok$'
just something else
$ grep -v success file | grep -v 'ok$'
just something else
To remove lines that contain both strings, specifically with grep:
grep -v 'success.*ok$' file
Example:
$ cat file
success something else
success ok
just something else
$ grep -v 'success.*ok$' file
success something else
just something else
I would try awk
awk '/success/ { next ; } /ok$/ { next ; } { print ;}' file
where
/success/ { next ; }
find wordsuccess
and skip line/ok$/ { next ; }
find lower caseok
and skip line{ print ;}
implicit else : print line
as per suggestion
short awk (thanks to Stéphane Chazelas )
awk '!/success/ && !/ok$/'
which is basically not (success) and not (ok at end of line )
golfed awk (thank to cas )
awk '! /success|ok$/'
which reuse regexp, and negate it