nate at refried.org wrote: > On Thu, Oct 23, 2003 at 01:53:59PM -0500, Chris Frederick wrote: > >>a script like this is doable: >>for file in dir >> ex "+:g/find/s//replace/" "+:wq" file >> >>but I can't help but think there's a better way, and one with more >>features like being able to recurse through directories, or is faster, >>etc. Is there a egrep/grep/etc tool that can do this? Or what tool >>would you recommend? > > > If you want to do things in-place you're already really close. I would > suggest using find to get the full list of files you want, grep those > for the files that need editting, then use ex to do the change. > > Something like this > > for file in `find /somedir -type f | grep -l <regex>`; do > ex <commands> $file > done > If you want a big speed improvement add xargs like this: for file in $(find /somedir -type f | xargs grep -l <regex>); do I prefer the $(command...) notation. It's a little easier to read at the end of a long day. -- Eric (Rick) Meyerhoff rick at eworld3.net 952-929-1659 _______________________________________________ TCLUG Mailing List - Minneapolis/St. Paul, Minnesota http://www.mn-linux.org tclug-list at mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-list