我是靠谱客的博主 英俊墨镜,这篇文章主要介绍MAC执行sed命令报“command c expects \ followed by text”错误解决办法,现在分享给大家,希望可以做个参考。

我在mac上执行sed命令nl numbers.txt| sed '2a bb'报错
sed: 1: "2a bb": command a expects followed by text
在stackoverflow上找到了几种解决办法:

Method 1:

brew install gnu-sed
alias sed=gsed

解释:
brew install gnu-sed下载GNU的sed,终端中默认的是BSD的sed。
然后用gsed代替sed命令就行了,如果还是想用sed命令,可以设置别名:
alias sed=gsed

Method 2:
如果你想要执行形如sed -i '1i text to prepend' file.txt的命令,在mac需要改成如下的亚子:

sed -i '' '1i
text to prepend
' file.txt

更多的解决方法来自:
stack overflow: SED command error on MACOS X

最后

以上就是英俊墨镜最近收集整理的关于MAC执行sed命令报“command c expects \ followed by text”错误解决办法的全部内容,更多相关MAC执行sed命令报“command内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部