SUMMARY: Searching all files

From: Paul Key <Paul_at_hsrc.org.uk>
Date: Fri, 8 Aug 1997 10:04:44 GMT

I have been inundated with responses to this question...thanks everybody -
too numerous to mention all your names. There are so many ways to crack a nut!

Here are a few of the responses:


###################################################


>From "Richard L Jackson Jr" <rjackson_at_portal.gmu.edu>

For example you want to search all files for the word fubar...

find / -type f -print -exec fgrep fubar '{}' \; >& /tmp/find.fubar

This says start searching from root, look at only files (not directories),
print searched filenames, execute fgrep for fubar, and send the results to
/tmp/find.fubar. Finally, when find ends, scan the /tmp/find.fubar for
fubar and note the filenames it was found in.

-- 
Regards,
Richard Jackson
Computer Center Lead Engineer
Mgr, Central Systems & Dept. UNIX Consulting
University Computing & Information Systems (UCIS)
George Mason University, Fairfax, Virginia
###################################################
try this:
cd /
find . -print -exec grep 'string' {} \;
-- 
Gary Jarrell                  |  1-800-354-9000 x30374 
Digital UNIX Technology Group |  MailStop:  ALF1-3/Q28 
Digital Equipment Corporation |  E-Mail:  jarrell_at_alf.dec.com 
5555 Windward Parkway West    |  Alpharetta, GA  30201-7407
###################################################
Jie Gao <jgao_at_csu.EDU.AU>,  Matthew Norcross <matt_at_CS.Princeton.EDU> and Tom
Webster <webster_at_ssdpdc.mdc.com> sent in PERL scripts that do the job...I
have yet to find the time to try them out!
And one shell script from Dan West <dwest_at_ad3100.ada.epa.gov>
I use the following shell script to search all files below the current
directory for a string
#!/bin/sh
if test $# -eq 0
then
        echo "Usage: search string"
        exit
fi
echo "find . -type f -print | xargs fgrep $1 /dev/null"
find . -type f -print | xargs fgrep $1 /dev/null
###################################################
Thanks again for the response!
Paul
_____________________________________________________________________
    |R|         A Message from Paul Key: Reginet Systems Developer
    |E|                  at 
    |G|         The Institute of Public & Environmental Health,          
    |I|         The University of Birmingham,           
    |N|         http://www.hsrc.org.uk
    |E|         E-mail        	: Paul_at_hsrc.org.uk
    |T|         Telephone 	: 0 (+44) 121 456 5600 Ext. 59876     
    | | 	Fax / Messages 	: 0 (+44) 121 454 6876
______________________________________________________________________ 
Received on Fri Aug 08 1997 - 11:23:16 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:36 NZDT