Jason Stelzer on 16 Oct 2008 08:36:11 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] CLI for "find" text string in an unknown file


On Wed, Oct 15, 2008 at 7:14 PM, Matt Mossholder <matt@mossholder.com> wrote:
> Try this:
>
>
> find <directory> -exec grep -l <string> {} \;
>

Couple fine points on this.

The grep on most linux systems can recurse directory trees so using
find isn't needed.

Using -exec with find is very inefficient. It forks off and execs the
command you specify for each file you find. For grepping this is over
kill. You would be better off building up a list of files and
executing grep once over all of them. There are situations where you
do actually need to use -exec, but those situations are fairly
uncommon.

grep -l <string> ` find <directory> `

Or, just grep -lr <directory>



-- 
J.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug