mac下用sed報錯 command c expects \ followed by text


一條很簡單的替換文本的命令:

sed -i 's/www.a.cn/www.b.com/g' common.js,報錯command c expects \ followed by text

但是同樣的命令在服務器上是可以正確執行的,看了mac下的man sed,里面-i選項中的解釋:

     Edit files in-place, saving backups with the specified extension.

             If a zero-length extension is given, no backup will be saved.  It

             is not recommended to give a zero-length extension when in-place

             editing files, as you risk corruption or partial content in situ-

             ations where disk space is exhausted, etc.

大概的意思就是說用-i的選項時mac會進行強制備份,所以你必須給出一個后綴名進行備份,如果你不想進行備份,直接用空字符即可

sed -i '' 's/www.a.cn/www.b.com/g' common.js


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM