find a file

Brian McKee brian.mckee at
Sun Aug 12 16:01:08 UTC 2007

On Mon, 2007-06-08 at 08:12 -0400, John Dangler wrote:

> As to the secondary question regarding grep, to find a specific word
> in a file (or files) in a directory, I usually do this little shell
> script, typed at the commandline-
> for word in `ls`
> do
> cat $word | grep "searchword"
> done
> That will search each file in a directory and tell you which files
> have the word you want (if any)
> I wouldn't recommend this for extremely large directories (or an
> entire disk).

Grep has a recursive option - save your typing :-)
grep $word -r $directory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the ubuntu-users mailing list