Command 'sed' stands for stream editor. You can use this command to edit streams (files) using regular expressions. But this editing is not permanent. It remains only in display, but in actual, file content remains same.
Look at the above snapshot, first we have performed 'sed' command on a string 'class7' where 'class' is changed into 'jtp' and 7 into 10. Then we have performed 'sed' command on a stream 'msg.txt' where 'learn' is converted into 'study'.
In earlier example, all 'learn' word were not edited into 'study'. To edit every word we have to use a global replacement 'g'. It will edit all the specified word in a file or string.
Look at the above snapshot, with command "echo class7 class9 | sed 's/class/jtp/g'" all the 'class' is converted into 'jtp' and with command "cat msg.txt | sed 's/learn/study/g'" all the 'learn' was converted into 'study'.
Removing A Line
The 'd' option will let you to remove a complete line from a file. You only need to specify a word from that line with 'd' option and that line will be deleted. But please note that all the lines having that same word will be deleted.
Look at the above snapshot, with command "cat msg.txt | sed '/jtp/d'" all lines containing word 'jtp' is deleted.