As a UNIX systems administrator, I am frequently asked how to find a particular pattern or string in a file in which the location of the file is unknown. This is a nifty recursive way of doing that. I routinely use it on the command line.
# /usr/bin/find /etc –type f | xargs grep –i PATTERN
These types of searches can take awhile depending on which directories you are searching.
- ux-admin said...
-
Tip: to speed the search up, use "-depth", and a case-sensitive `grep`, like so:
find /a/path/ -depth -type f -print | xargs grep the-string-you-are-looking-for
6 comments:
Tip: to speed the search up, use "-depth", and a case-sensitive `grep`, like so:
find /a/path/ -depth -type f -print | xargs grep the-string-you-are-looking-for
Appreciate the tip ux-admin
I've used this to varying degrees of success.
find /a/path -depth -type f -exec grep -l (text you want) {} \;
xargs sometimes barfs if you pass it too many files...
wad, I'll try your method.
grep -r
not all grep are created equal. some do not have the -r switch
Post a Comment