Tuesday, 17 December 2013

Unix - Remove range of lines from a file

In Unix, we have the ability to remove certain lines from a file by using sed. Sed as you may be aware, is a short for stream editor. Using Sed, we can specify the range of lines which we want to delete.

Usage :

sed -i <beginning line no> <ending line no> <file-name>

Eg:

For deleting lines from 3 to 9 of a file Test.txt, use the following command

sed -i '3,9 d' Test.txt

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker