[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

global search and replace



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'.

Anyway, I'm very interested in learning other options.

TIA
zen



Reply to: