Perl: Find and replace specific string in multiple text file

后端 未结 6 837
甜味超标
甜味超标 2020-12-30 08:05

I need to get all the .config file in a given directory and in each of these file I need to search for a specific string and replace with another based on the file.

6条回答
  •  粉色の甜心
    2020-12-30 08:52

    If you are on Unix like platform, you can do it using Perl on the command line; no need to write a script.

    perl -i -p -e 's/old/new/g;' *.config
    

    TO be on the safer side, you may want to use the command with the backup option.

    perl -i.bak  -p -e 's/old/new/g;' *.config
    

提交回复
热议问题