How can I use find command in Unix to search two expression at a same time.
I am using following syntax to find the files containing $id expression.
find . -exec grep $id '{}' \; -print
How can I use the same command to search two strings at a same time.
I want to search the files in subdirectories also.
Any suggestions ?
If it is not possible with find, what command I can use to achieve same result ?
Thanks in advance.
Find command in Unix?
One way is to use egrep which lets you search for multiple strings using the | operator.
find . -exec egrep "$id1\|$id2" {} \;
But perhaps it's easier for you to use egrep with the -r (a.k.a.: --recursive) option instead of using find. GNU grep is very powerful these days - run egrep --help to see all of the interesting options.
Reply:Try this one....locate -exec grep $id and 'a new one here ' '{}' \; -print
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment