How to do a recursive find/replace of a string with awk or sed?

后端 未结 30 1608
盖世英雄少女心
盖世英雄少女心 2020-11-22 06:39

How do I find and replace every occurrence of:

subdomainA.example.com

with

subdomainB.example.com

in eve

30条回答
  •  终归单人心
    2020-11-22 07:26

    This one is compatible with git repositories, and a bit simpler:

    Linux:

    git grep -l 'original_text' | xargs sed -i 's/original_text/new_text/g'
    

    Mac:

    git grep -l 'original_text' | xargs sed -i '' -e 's/original_text/new_text/g'
    

    (Thanks to http://blog.jasonmeridth.com/posts/use-git-grep-to-replace-strings-in-files-in-your-git-repository/)

提交回复
热议问题