Mass File Edit

by @jehiah on 2005-08-29 20:07
Filed under: All

Often times I want to edit a whole slew of files at once, changing only a simple string. But it's the same change in all the files.

The solution for this has eluded me till now (worst yet.. it's a simple solution. A classic one liner.)

perl -pi.bak -e 's/oldstring/newstring/' *.py

Simply put this changes every occurrence of "oldstring" to "newstring" in .py saving the original files as .py.bak

then verify it did what you wanted and delete the .bak files

Subscribe via RSS ı Email
© 2021 - Jehiah Czebotar