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
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!