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