[comp.unix.shell] grep

davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (10/24/90)

Lots of people have given you ideas on this, I'll just add that if you
have a large number of non-text files in this structure, you can save
time by using the "file" command to identify the text files.

Something like:

    $ find . -type f -print | xargs file | grep " text" |
    > sed 's/:.*$//' | xargs grep PATTERN /dev/null

  While this looks like a lot of stuff, it will be vastly faster than
searching all the non-text files and getting possible bizarre matches on
binary code or other strings. I invented this when desparate enough to
look for a string in /usr.

Note: I cross posted this item *only* to the shell group, followups by
default to the original group.
-- 
bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
    sysop *IX BBS and Public Access UNIX
    moderator of comp.binaries.ibm.pc and 80386 mailing list
"Stupidity, like virtue, is its own reward" -me