Tuesday, January 11, 2011

Batch replace a string in several files

At your command prompt type the following

perl -p -i -e 's/oldstring/newstring/g' `grep -il oldstring *`

'oldstring' will be replaced by 'newstring' in all folder files

You can add change the grep command to "grep -ilr oldstring *" in order to make searching recursive

No comments:

Post a Comment