views:

35

answers:

2

I want to find the lines in which atleast one of the strings among string1 and string2 are present in the file.

grep 'string1' 'string2' file;-this is an error even though!!

how could i do the above on unix command line?

A: 

Found it!!

grep -e 'string1' -e 'string2' file;
Vijay Sarathi
why a down vote for this ?please add a comment
Vijay Sarathi
+1  A: 

If your version of grep supports the -E flag (e.g. the GNU version), you can use extended regular expressions, which allows you to perform queries like this:

$ grep -E 'string1|string2'

or

$ grep -E 'string[12]'

See pcresyntax(3) and pcrepattern(3) for further information on PCRE (Perl Compatible Regular Expressions).

jkramer