toooki
asked on
UNIX grep command question
Is there any way to use grep command to output all lines in a file that has either string "abc" orstring "pqr" or string "xyz" in it?
# cat filename.txt | grep "abc"
I know above works but I want to include in output lines containing string "pqr" or string "xyz" as well. (Also the lines need to be in sequence as in the original file.)
# cat filename.txt | grep "abc"
I know above works but I want to include in output lines containing string "pqr" or string "xyz" as well. (Also the lines need to be in sequence as in the original file.)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wow... sorry... thought -e was part of the base. We run AIX/HPUX/LINUX
ASKER
Ok no problem.
Many thanks for your help.
Many thanks for your help.
ASKER
#egrep "abc|pqr|xyz" filename.txt
The above command worked the way I wanted.
#grep -E 'abc|pqr|xyz' filename.txt
above gave me error:
grep: illegal option -- E
Usage: grep -hblcnsviw pattern file . . .
Also similar error with:
grep -e abc -e pqr -e xyz filename.txt
..
Mine is Solaris 9 server:
#uname -a
SunOS bingofish 5.9 Generic_118558-39 sun4u sparc SUNW,Ultra-60