Sed - sed: -e expression #1, char 28: unknown option to `s'


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/

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM