Darren Beale Web developer & early adopter

Search and replace multiple files with sed

S

Ok, if you ‘do’ linux then you’ll probably already know this one. I did, kinda, but had to Google to remind myself of the exact chain of commands. So here I am writing it down so it’s easier to find next time.

In my case I had a load of apache conf files where I needed to replace each occurence of an IP address with an asterisk. A combo of find and sed worked well:

find /etc/apache2/sites-available -type f -exec sed -i 's/192.168.255.2/*/g' {} ;

By bealers
Darren Beale Web developer & early adopter