The problem is with slashes: your variable contains them and the final command will be something like sed "s/string/path/to/something/g"
, containing way too many slashes.
Since sed
can take any char as delimiter (without having to declare the new delimiter), you can try using another one that doesn't appear in your replacement string:
replacement="/my/path"
sed --expression "s@pattern@$replacement@"
/home/scnzzh/zzh $> sed 's@/PATH@/path@' b.txt binpath=/path/TO/SCRIPTS/ aa_binpath=/path/TO/AA/ /home/scnzzh/zzh $> sed 's|/PATH|/path|' b.txt binpath=/path/TO/SCRIPTS/ aa_binpath=/path/TO/AA/