use an OR in grep
April 26th, 2007 by Lawrence David
to search for either of two arguments in grep, you’ll need the usual or character: vertical bar “|”. however, you’ll also need to add a backwards slash in front:
$ grep “str1\|str2″ my_file.txt
April 26th, 2007 by Lawrence David
to search for either of two arguments in grep, you’ll need the usual or character: vertical bar “|”. however, you’ll also need to add a backwards slash in front:
$ grep “str1\|str2″ my_file.txt
Your whole website is a great work, its very nice
I have added two similar solutions:
$ awk ‘/str1|str2/’ file.out
$ sed -e ‘/str1/b’ -e ‘/str2/b’ -e d file.out
//Jadu
http://unstableme.blogspot.com
thanks for the ideas jadu!
What about egrep ?
$ egrep “str1|str2″ my_file.txt
Thanks for the tip, it was just what I was looking for!
(checking out the rest of your site now)