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.
I didn't know that you could do */*.html and such in a filemask (although now that I think of it, why not?), so that's a useful bit of information. Don't think it'll be much help though in my case because the directory tree in question is pretty deep.
Jacob
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
