|
How to grep for two or more words in a line at the same time?
I want to search a heap of files but using an either OR or AND condition for two or more strings. How can I do this?
i.e. file1 has the following
file testfile primary
and file2 has this ...
file testfile2 secondary
If I use this ...
find . -type f -exec grep "testfile" {} /dev/null \;
I get BOTH files.
However, I want to use something that will give me the 1st file if I say something like ...
find . -type f -exec grep "file&&testfile" {} /dev/null \;
This actually did not work under C shell or Korn shell.
I also tried egrep "file&&testfile" and it too did not work.
In VMS (here we go! hehehe)... it was so easy ...
search *.src file, testfile /match=and
Thanks in advance
|