I have script file which replaces one word with other in files .
this is piece of code I use .now the problem I face is when Var1 and Var2 are path names .I m pretty new to shell scripting .I know i should put a escape sequence in front .since var1 and var2 are read from csv files i cant manually put escape sequences on them .is ther a way to detect the special charaters before this command and replace them with escape sequence
$f is a file name
sed -i "s/$Var1/$Var2/g" "$f"
hy,
you can use a different character for separating statement :
the first character seen by sed, after the command, will be used for separating your patterns.
In your example, this could be :
then
$Var1and$Var2could hold any/but not%.if you have to use the separator as pattern, you must escape it with
\.