You had asked about the SED then I think that here it is that can clear the idea behind the SED command. If you would ask me if Linux has the Search and Replace feature then I would say that it is the SED command. This command can be used to revolutionize all occurrences of one string to another that are present within a single file. It is just like the search-and-replace feature that is possessed by the word processor. Also for deleting the range of lines from a file the SED command can be brought into play. The syntax for the SED command is as follows:
If you want to have the Substitution then
Code:
sed 's/<oldstring>/<newstri ng>/g' <file>
If you want to have the file deleted then
Code:
sed '<start>,<end>d' < file>
As an example if you want you can replace the word lamb with the word sheep in the file Marry.txt using the SED command as follows: sed 's/lamb/sheep/g' Marry.txt.If the file Marry.txt was having the content like: Mary had a little lamb then after executing the command it will change to: Mary had a little sheep. Hope that you would have understood the SED command and the use of the same.
Bookmarks