using the CAT command recursively


Recommended Posts

I need to search for a specific phrase in a bunch of files that are all in subfolders by month.

I know I can do a

cat * | grep <phrase>

in each folder but how would I run this from the top level and get it to look in all the folders? something to do with

ls -R

?

Link to comment
Share on other sites

for f in `ls -R`; do cat "$f" | grep <phrase>; done

You'll have to ignore all the directory warnings, or add more filtering.

That appears to get stuck :/

Link to comment
Share on other sites

Yeah, Im going to have to agree with trpn, this is how you can search from the top directory down.

grep -r whatever *

I use that every day when I am looking for spammers or whatever in log files.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.