Friday, June 28, 2013

Find & Replace in multiple files

Sometimes this is needed in order to replace one string with another in multiple files. In my case I had to replace an old string with a new one within the same directory.

Below is the command that helped me to save a lot of time and did the trick:

sed -i "s/${old}/${new}/g"  ${directory}*

Also, you might want to change file permissions to 777 prior to running this command and then change the permissions back to what they were.

Good luck!

No comments:

Post a Comment