PDA

View Full Version : Linux, how to replace text in files recursivelly



Fli
03-24-2013, 01:58 PM
This linux command to search and replace in files, should work. But dont use it if you dont know what are you doing. Such commands can bulk change files irreversibly.


find . -name '*.ini' -type f -print0 | xargs -0 sed -i 's|oldstring|newstring|g'

What above command should do? search files with extension .ini in current directory and its subdirecotires. find "oldstring" and replace it by "newstring".

example if u want to search / replace phrasse containing
$
/
*
.
i think you have to add backslash before it.

example:

\*\.php