Perl: Find and replace specific string in multiple text file

后端 未结 6 833
甜味超标
甜味超标 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:58

    Perl here is just to modify files... I don't understand why to write it whole in perl if you can do it much simpler like this:

    find . -maxdepth 1 -type f -name '*.conf' | \
        xargs perl -i.bak -pe 's/localhost/example.com/;'
    

提交回复
热议问题