Michael Marsh wrote:
On 10/8/05, Nevruz Mesut Sahin <[EMAIL PROTECTED]> wrote:
Hello how can I find files which contents a string in it. For example
/www/xyz/hdx.php. File hdx.php conteins "welcome here" and I want to seach
all system( / ) which conteins "welcome here" then machine shows
/www/xyz/hdx.php. Thanks
I'd use
$ find / -name '*' -exec grep -l "welcome here" {} \;
I'd always include a -type for something like that, otherwise what
happens is that grep tries to run on some pipe in /dev/ and hangs forever.
find / -name '*' -type f -exec grep -l "welcome here" {} \;
This assumes that the file is of type f=regular file. For other types
see the find man page:
-type c
File is of type c:
b block (buffered) special
c character (unbuffered) special
d directory
p named pipe (FIFO)
f regular file
l symbolic link
s socket
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.
--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]