美文网首页
sed -i 在Mac OS不能用

sed -i 在Mac OS不能用

作者: 谢昆明 | 来源:发表于2017-03-08 17:45 被阅读17次

    From the sed manpage:

    -i extension
    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.

    Aha, it wants to save a backup file. So I changed my command to:
    sed -i '.bak' 's/apples/oranges/' file.txt

    The solution is to send a zero-length extension like this:

    sed -i '' 's/apples/oranges/' file.txt
    

    打赏

    如果这篇文章解决了您的问题,让我买根烟抽抽。

    支付宝.jpg 微信.jpg

    相关文章

      网友评论

          本文标题:sed -i 在Mac OS不能用

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