From: kevin lyda (kevin at domain suberic.net)
Date: Thu 26 Aug 1999 - 16:49:40 IST
Miles spoke thusly:
>How would I go about searching for an occurrence of a word in a folder
>with multiple subdirs, and have it search those subdirs recursively for
>the word as well? There isn't any '-R' flag or the like for grep, is there
>(a la cp -R or cmod -R)?
find /dir/to/search -type f -exec grep term '{}' /dev/null ';'
or
find /dir/to/search -type f -print | xargs grep term /dev/null
or some linux boxes have an rgrep command.
(the /dev/null on the grep command line is there to make sure grep
prints out the name of the file if only one filename is given
to grep by find or xargs. actually find always puts a single
filename which is why it's less efficient then xargs. sunos's
find command had a -exec that could end in a '&' instead of a ';'
which would make it put lots of matches onto a -exec'ed command.
ah, those were the days. gee this is a long paranthetical comment)
kevin
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:30 GMT