sed command with -i option failing on Mac, but works on Linux

前端 未结 12 1892
情歌与酒
情歌与酒 2020-11-22 05:04

I\'ve successfully used the following sed command to search/replace text in Linux:

sed -i \'s/old_link/new_link/g\' *

However,

12条回答
  •  别跟我提以往
    2020-11-22 06:01

    This works with both GNU and BSD versions of sed:

    sed -i'' -e 's/old_link/new_link/g' *
    

    or with backup:

    sed -i'.bak' -e 's/old_link/new_link/g' *
    

    Note missing space after -i option! (Necessary for GNU sed)

提交回复
热议问题