Michael Marsh napisał(a):
I'd use $ find / -name '*' -exec grep -l "welcome here" {} \;
Aaaargh. One of the ugliest monsters I've ever seen ;-P
The nice thing about using find is that you can limit the depth of the search, restrict it to directories on the current filesystem, specify a more restrictive filename pattern, or perform other tests. It's also good to know how to use with the "-exec" flag because it can essentially make any command recursive.
Basicaly right, but you should limit the exec feature as much as you can. With your find, you're spawning a new process for every file you find. Horrible solution. If we want to use the flexibility of find to limit the search, so we can't just use "grep -r 'whatever' *", we can use print (print0 is even better) and xargs.
So we would end with something like this find / -name '*.php' -print0 | xargs -0 grep -l 'whatever'