On Mon, 2003-09-15 at 14:30, Ross Werner wrote:
> On Mon, 15 Sep 2003, Jacob Fugal wrote:
> > Many times I've run into a situation where I want to grep somethingin
> > every file of a particular type in a certain directory tree recursively.
> > For example, find all the html files (*.html filemask) containing
> > 'substr' in myDir/.
> >
> > I can write my own script to choose the files and then apply grep to
> > them, and I can apply a find/xargs combo, but I was just wondering if
> > anyone knew of some other elegant, 'shweet' way of doing this?
>
> I don't have an elegant nor "shweet" way of doing it, but I found online
> somewhere this:
>
> grep 'substr' *.html */*.html (and even needed, another */*/*.html)
>
> which will work for 99% of the things you want to do. It's not elegant, by
> any definition of the word, but it's a quick hack and it's a few
> keystrokes shorter than your piping-to-egrep version.
Or, alternatively,
find . -name '*.html' -exec fgrep 'substr' {} \; -print
More keystrokes, but it will recursively follow all directories and grep
on all files whose names match '*.html'.
-Hyrum
--
Need an Open Source Genealogy tool? Help write one!
http://openancestry.sourceforge.net/
____________________
BYU Unix Users Group
http://uug.byu.edu/
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list