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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file searching 1

Status
Not open for further replies.

apocalypse11

Technical User
Jan 11, 2001
77
AU
ok... I need to find a file based on its content... how do I do this.

Thanks.
 
You will need to use the "grep" command. For example if you are looking for "Hello there" and all the files are in the same directory, try:

grep "Hello there" *

If you don't know in which directory the file is, you will also need the "find" and "xargs" commands. First you will need to change to the directory that will be starting point of your search and then type:

find . -print|xargs grep "Hello there"

or

find . -print -exec grep "Hello there" {} /dev/null \;
 
Try something like this:
Code:
find /path/to/dir -type f | xargs grep "String searched"

Hope This Help
PH.
 
Or, if using GNU's grep:

[tt]grep -lr "string" /directory[/tt]

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top