Replace Text in Multiple Files

January 14th, 2012 | By: | BASH Script Tutorials | No comments »

This is a problem that could come across quite often. How to replace text in multiple files at once?

If you are running a UNIX system you are lucky: with a simple BASH script you can achieve this.

How to Replace Text in Many Files with BASH scripting

There are several ways to achieve this, one of the easiest is using sed utility.

Assuming we need to change every “blue” occurrence to “red”, our replace_string.sh would look something like: