UNIX Programming, Certification, System Administration, Performance Tuning Reference Books
Finding a String

How to find a string somewhere on the system?

Many times we are called to search for a string, but we have no idea where it may be lurking. Judicious use of the find and grep commands will make you a hero with your co-workers.

# find . -type f -exec grep "string or options" /dev/null {} \;

Normally using only:
# find . -type f -exec grep "string/options" {} \;

Produces the target string, but you will have no clue as to where it is located, making this almost as frustrating as using windoze! Remember when grep'ing against multiple files the filename will be listed before the match.

$ grep there *
foo:I found the target here
bar:You are there

Return to : Unix System Administration Hints and Tips