×
Create a new article
Write your page title here:
We currently have 3,185 articles on s23. Type your article name above or click on one of the titles below and start writing!



s23
3,185Articles

Perl/One-Liner

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"`
Cookies help us deliver our services. By using our services, you agree to our use of cookies.