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

后端 未结 30 1579
盖世英雄少女心
盖世英雄少女心 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:19

    Simplest way to replace (all files, directory, recursive)

    find . -type f -not -path '*/\.*' -exec sed -i 's/foo/bar/g' {} +
    

    Note: Sometimes you might need to ignore some hidden files i.e. .git, you can use above command.

    If you want to include hidden files use,

    find . -type f  -exec sed -i 's/foo/bar/g' {} +
    

    In both case the string foo will be replaced with new string bar

提交回复
热议问题