Recursive search and replace in text files on Mac and Linux

后端 未结 14 754
不思量自难忘°
不思量自难忘° 2020-12-02 04:18

In the linux shell, the following command will recursively search and replace all instances of \'this\' with \'that\' (I don\'t have a Linux shell in front of me, but it sho

14条回答
  •  执笔经年
    2020-12-02 04:44

    A version that works on both Linux and Mac OS X (by adding the -e switch to sed):

    export LC_CTYPE=C LANG=C
    find . -name '*.txt' -print0 | xargs -0 sed -i -e 's/this/that/g'
    

提交回复
热议问题