This is a very common needs, to search a keyword and replace it with another. Give you a simple example, when I want to perform a ubuntu distribution upgrade from dapper to edgy, I need to edit the file /etc/apt/sources.list.
To do that i can either uses vim, or simply uses sed.
The vim way.
sudo vim /etc/apt/source.list
When in vim, you can do this
%s ask vim to search for every line, and replace dapper to edgy. By default, it will only replace the first “dapper” it found in a line, the /g will indicate it replace all “dapper” in a line.
The sed way.
sudo sed -e 's/dapper/edgy/g' -i /etc/apt/sources.list
-e is the script function, it performs search and replace like vi, and -i is the edit the file in place.