狂欢‰一夜 发表于 2017-7-8 12:55:07

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
页: [1]
查看完整版本: mac下用sed报错 command c expects \ followed by text