Summary: grep for a word in the whole filesystem

2007-12-24 22:14:00

Thanks to all. I received tons of email.

Here are what I found useful:

find . -type f -exec grep -li foo {} \;
find . -type f | xargs grep "foo"
find . -type f -exec printf "'%s'\n" {} \; | xargs grep foo /dev/null
find . -type f -print |xargs grep -l "foo"
find . -depth -type f -exec grep 'foo' {} \; -print
find . -type f -exec strings {} \; | grep foo

find <path_filesys> -xdev -type f -exec grep -w <word> {} /dev/null \;

-xdev will stop you crossing mount points
/dev/null will show the file that matches the string and also the string
match

rgrep from http://www.shelldorado.com/scripts/cmds/rgrep.txt

Sincerely,
Dan

>From: "Dan Lee" <koinonia98 at hotmail.com>
>To: codeprof at codeprof.com
>Subject: grep for a word in the whole filesystem
>Date: Wed, 20 Mar 2002 17:22:25 -0500
>
>Folks,
>
>Is there a way to grep for a pattern in the entire filesystem? I would
>like
>to be able to grep for example the word "foo" without the knowledge of
>where
>it is located. It can be in any directories or partitions. Do I use a
>combination of find and grep? Hopefully, it will skip any binary
>executable
>files within the search to avoid the command being hang.
>
>TIA,
>dan
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
>_______________________________________________
>codeprof mailing list
>codeprof at codeprof.com
>http://www.codeprof.com/execute/ask/?codeinfoid=12067

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx

Comments

Got something to say?

You must be logged in to post a comment.