From S23Wiki
Jump to: navigation, search

Replace every occurrence of OldText with the text NewText.

$ perl -pi -e s/OldText/NewText/g file.txt

If you have several text files and want to replace some text in them you could use the powerful find command. The Perl code below shows how you can replace a text in every file called .conf.

$ perl -pi -e s/OldText/NewText/g `find . -name "*.conf"`