[lug] simple text editing problem

Rob Nagler nagler at bivio.biz
Thu Aug 22 12:17:51 MDT 2002

Jeff Schroeder writes:
> You could use vi (or a clone like Elvis) in conjunction with a find 
> command...
> vi `find -name "*.c" -exec grep -l <regexp> {} \;`

I find:

grep -Irl <regexp>

to do the right thing.  *.h is missing above.

You can do it all in one line with:

perl -pi.bak -e 's/<old>/<new>/g' $(grep -Irl '<old>')

If you want to filter on name, just do:

perl -pi.bak -e 's/<old>/<new>/g' $(grep -Irl '<old>' | grep '\.[ch]$')


More information about the LUG mailing list