I would like to grep for two statements in a file at a time.?
I would like to grep for two statements in a file at a time.
I want to find out if my file contains both the statements in it or not.
Thanks in advance,
Do we have and operator in UNIX?
- 1 decade agoFavorite Answer
grep -E "expression1|expression2"Source(s): http://unixhelp.ed.ac.uk/CGI/man-cgi?grep
- 1 decade ago
I am assuming you are in a UNIX shell.
you can you a if statement with test to find multiple results.
if [ $( $(cat mylife | grep wordone) | wc -l ) -ne 0 ] ; then
if [ $( $(cat mylife | grep wordtwo) | wc -l ) -ne 0 ] ; then DO THIS; fi
fiSource(s): Bart G. Colbert UNIX Sys Admin, Programmer http://www.intencities.net