Quantcast
Channel: Ian Chilton » Linux
Viewing all articles
Browse latest Browse all 7

Find and Replace Across Multiple Files

$
0
0

Have you ever needed to change the same thing in a load of files and have had to sit there and go through each one in turn and make the same change?

This is a really useful and simple command:

perl -pi -w -e 's/from text/to text/g;' *

It simply goes through all files matching * and runs the regular expression, ‘s/from text/to text/g’ – which means replace all instances of “from text” with “to text”.  nifty!


Viewing all articles
Browse latest Browse all 7

Trending Articles