On Thu, 17 Jun 2004 08:46:38 +1000 Zenaan Harkness <[EMAIL PROTECTED]> wrote:
> What do people use for multi-file/ multi-directory search and replace? > > I use something like this: > > find . -name \*java|xargs perl -p -i.bak -e 's/searchRE/replaceRE/g;' > > However, I would also like to see which files actually got changed. > > With the in-place option (-i[backup-extension]), every file is > touched, even if it is not changed, which means I can't then just find > all files with the .bak extension to find out which ones were changed. > > Ideally, even lines numbers, ala grep -n. > > I guess one option is simply to run a grep with the 'search' pattern: > > find . -name \*java|xargs grep -nC3 'search'. When I had to look for a specific e-mail address and replace it in about 60MB of php files several months back, I used treesed.pl. You can download it from: http://www.perl.com/pub/r/118 . There's a little bit of documentation at the top of the script, and a little bit more available from http://www.uwo.ca/its/doc/hdi/web/treesed.html (though it's really not that hard to use). Note, however: the version of Perl it was written for makes it work great in Woody, but anything newer is likely to error out. I haven't taken the time to try and update it as all my servers are still running Woody. HTH, Jacob -- GnuPG Key: 1024D/16377135 Random .signature #32: I prefer an OS made by programmers that needs marketing than an OS made by marketing that needs programmers... http://www.linux.org
pgpjWwtjzqIgh.pgp
Description: PGP signature