Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching file contents.

Status
Not open for further replies.
Jun 28, 2002
64
GB

Does any one know how to recursivly search through the contents of files and directories using grep ? I thought there was a switch to recursivly search ?

I am searching for the hostname of a unix machine in many subdir's.

I have looked at at fgrep and egrep and they seem to have the same switches..



Paul.
 
Hi Paul,

find . -type f -print | xargs grep -i [PATTERN]

will search recurively for a pattern - taken from the Bigadmin site. Regards.
 
Also (found in a newsgroup):

find . -name 'pattern' -exec grep pattern '{}' /dev/null \;

The /dev/null causes grep to think it is searching two filesand gives the proper
file: textoutput as one would get when grepping many files in single directory.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top