I am trying to write a shell script to replace the SEARCH string by REPLACE string in all the files of the current directory (directory where my script remains).
The condition I have is : the script should replace the 'search string' to 'replace string' in all the files except my shell script.
I tried sed command in console. It worked as I have expected. But when I added this sed command to my script, it throws an error.
The command in my script(replace.sh) is :
search_str=is;
replace_str=IS;
sed -i.bak s/$search_str/$replace_str/g !(replace.sh)
The error I get is:
./replace.sh: line 11: syntax error near unexpected token '('
./replace.sh: line 11: 'sed -i.bak s/$search_str/$replace_str/g !(replace.sh)'
Hope you can help me.. Thank you in advance..
shop
extglob withshopt -s extglob
in your script.