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!

Searching for specific value witin files in a directory

Status
Not open for further replies.

hugheskbh

Programmer
Dec 18, 2002
37
US
Can anyone tell me if there's a way to scan for a specific value within all the files of a directory with one command.
 
You can try something like this:
Code:
grep 'ValueSearched' /path/to/dir/*
If you get Arg list too long you can try this:[/code]
cd /path/to/dir; grep 'ValueSearched' *[/code]
If you still have too many files, try this:
Code:
cd /path/to/dir; ls | xargs grep 'ValueSearched'

Hope This Help
PH.
 
If you want to recursively search the directory and other directories that may be therein, try:

find /path/to/dir -type f | xargs grep 'ValueSearched'

Cheers,

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top