[email protected]
[Top] [All Lists]

Re: find a file

Subject: Re: find a file
From: Smoot Carl-Mitchell
Date: Mon, 06 Aug 2007 11:28:19 -0700
On Mon, 2007-08-06 at 22:42 +1000, Karl Auer wrote:
> On Mon, 2007-08-06 at 08:21 -0300, Allan Valeriano wrote:

>    find . -name "*.txt" -exec grep help {} \; -print

Slightly easier syntax is:

find . -name "*.txt" -exec grep -H help {} \;

The -H switch prints the filename on each matching line in each file.
You normally do not need this, since grep's default is to print the
filename if there is more than a single file in the argument list.

Or if you want to avoid find altogether you can do something like this:

grep -r --include="*.txt" help .

You need the quotes around the *.txt or otherwise the shell will expand
the "*" before it is passed to grep.

See the grep manual page for all the gory details.
Smoot Carl-Mitchell
System/Network Architect
email: [email protected]
cell: +1 602 421 9005
home: +1 480 922 7313

ubuntu-users mailing list
[email protected]
Modify settings or unsubscribe at: 

<Prev in Thread] Current Thread [Next in Thread>