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!



< Perl
Revision as of 14:41, 4 July 2005 by imported>mutante
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.