美文网首页
mac上遇到的错误sed command a expects f

mac上遇到的错误sed command a expects f

作者: 是立品啊 | 来源:发表于2020-08-31 22:44 被阅读0次

    上简单的替换操作

    sed -i 's/apple/mac/g' full-path-file
    执行后报错,“sed: 1: command a expects \ followed by text”
    由于mac系统与linux系统下sed用法的差异,下面给出两种解决方案
    (差异可自己在两个系统用man命令查看帮助)

    第一种解决方案

    将sed命令改写为

    sed -i '' 's/apple/mac/g' full-path-file
    

    第二种解决方案

    调整mac下sed的用法,使其与linux一致
    mac上安装gnu-sed

    brew install gnu-sed
    alias sed=gsed
    

    调整后两系统下sed的用法完全一致。

    相关文章

      网友评论

          本文标题:mac上遇到的错误sed command a expects f

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