Monday, March 01, 2010

Replace string with shell script parameter using sed command

In order to change string inside a file using shell script I used the following command in the shell script, where inside myFile.xml, oldString is the string I want to replace with the string contained in the first parameter passed to the shell script.

sed -i 's/oldString/'"$1"'/g' /home/healthy/myFile.xml

No comments: