Friday, 3 August 2018

Linux: sed - Delete a line

As we discussed in the above section about the power of SED command, here we discuss about the how to use SED command to delete a line in a file.
How to delete first line using SED command
sed 'Nd' sample1.txt
Note: ‘N’should be replaced with the line number which we want to delete 
           ‘d’ is the command used to delete.
 
How to delete a particular line using SED command
sed '4d' sample1.txt
How delete last line in a file using SED command
sed '$d' sample1.txt
Note: ‘$ ‘indicates the last line of a file
In the next article will learn more about SED commands.

0 comments:

Post a Comment