In sed, if a pattern can be included inside of single quotes, no variable will be extented. Exmple 1 and 2. In order to use value of a variable, the pattern need to be included by double quotes and use "#" instead of "/" for seperator. See example 3 and 4.
-  sed -i 's/\[filename\]/myfile/g' ${file}.new------>succ.
 -  sed -i 's/\[filename\]/$file/g' ${file}.new------->variable is not extended.
 -  sed -i "s/\[filename\]/$file/g" ${file}.new------->fails( Unknown option to 's')
 -  sed -i "s#\[filename\]#$file#g" ${file}.new-------->succ.
 
 
No comments:
Post a Comment