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