Pages

Friday, September 17, 2010

How to remove first line of a file in Shell Script ?

To remove first line of a file in Shell Script, we can
use 'sed' command.


say for example,

cat one.txt 

Line 1
Line 2
Line 3
Line 4
Line 5
Line6

To remove first line from the file, use

sed -i '1d' one.txt

which will give you,


Line 2
Line 3

Line 4
Line 5
Line 6

To remove lines from 2 to5, use

sed -i '2,5d' one.txt

which will give,

Line2

No comments:

Post a Comment