Saturday, November 24, 2012

Replace a string in file using shell script

Suppose my file a.conf is as following
Include /1
Include /2
Include /3
I want to replace "Include /2" with a new line, I write the code in .sh file : 
line="Include \\/2"
rep=""
sed "s/${line}/${rep}/g" /root/new_scripts/a.conf > /tmp/a.conf-new
 
mv /tmp/a.conf-new /root/new_scripts/a.conf 

No comments:

Post a Comment