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

前端 未结 12 1914
情歌与酒
情歌与酒 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:08

    Sinetris' answer is right, but I use this with find command to be more specific about what files I want to change. In general this should work (tested on osx /bin/bash):

    find . -name "*.smth" -exec sed -i '' 's/text1/text2/g' {} \;
    

    In general when using sed without find in complex projects is less efficient.

提交回复
热议问题