Search And Replace in Multiple Files Using Perl
Hold on Cowboy
This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.
perl -pi -w -e 's/search/replace/g;' *.php
-e means execute the following line of code. -i means edit in-place -w write warnings -p loop
Example I had the following style sheet in a section:
and I wanted the following instead:
As each expression is a regular expression you’ve got to escape the special characters such as forward slash and . ../includes/style.css
So the final line of code ends up as perl -pi -w -e ‘s/../includes/style.css/admin.css/g;’ *.php