美文网首页
macos的sed命令报错 command c expects

macos的sed命令报错 command c expects

作者: 闲睡猫 | 来源:发表于2019-03-19 22:50 被阅读0次

macos的sed命令太坑人了,同样的命令,在linux执行完全没问题,macos中就直接报错:command c expects \ followed by text

在stackoverflow找到了解决方案,macos中要使用gsed来替代sed

brew install gnu-sed

安装完毕后,使用gsed替换sed,当然,你也可以作个别名:alias sed=gsed

但当与find相结合时,别名并不起作用,依然需要使用gsed, 否则会报 invalid command code .

find ./ -exec sed -i '/text/d' {} \;

相关文章

网友评论

      本文标题:macos的sed命令报错 command c expects

      本文链接:https://www.haomeiwen.com/subject/bfwomqtx.html