Sed – stream editor is a powerful tool to manipulate strings. It will take STDIN as well as operating on a file:
The most common usage is to replace text: echo “this is a test string” | sed s/i/z/g will replace every instance of ‘i’ with a ‘z’: thzs zs a test strzng
You can delete a particular word with say echo “this is a test string”| sed s/test//g leaving: this is a string
You can operate on a file with:
echo “this is a test string” >> file; sed -e s/test//g file Leaving: this is a string
You can also use regular expressions with sed.