sed offers a lot of commands that can be used to insert, change, delete, and transform text with ease. Let's see some examples of how to use these commands with sed.
Other sed commands
The delete command
You can use the delete command d to delete lines or a range of lines from your stream. The following command will delete the third line from the stream:
$ sed '3d' myfile
The following command will delete the third to the fifth line from the stream:
$ sed '3,5d' myfile
This command will delete from the fourth line to the end of the file:
$ sed '4,$d' myfile
Note that the deletion happens only to the stream, not the actual file. So if you want to delete from the actual file, you can...