A simple example of SED

The basic command for replacing occurences of a particular string in a file to another string and output to a new file:

Let’s call our source file file1

sed 's/'old string'/'new string'/' file1

Example
sed 's,'CONFIG_TUN=m','#CONFIG_TUN=m','lconfig

This will output the replaced text to screen. If you want to make changes in the file, you need to pipe it to a new file and finally move the file back to original name.

sed 's/'old string'/'new string'/' file1 > file2 ; mv file2 file1[/code]
And to test if it was successful:
grep -i 'new string' destinationfile

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.