Hi
I am using the following command to delete a line from the file by line number:
line_number=14
sed "${line_number}d" inputfilename > newfilename
Is there a way to modify this command to specify the range of lines to be deleted, lets say from line 14 till line 5 ?
I tried using the while loop but execution takes too long.
Thanks a lot
h112
2
Maybe ex editor can aid you in such task see here
See if this works for you:
line_From=14
line_To=17
sed "${line_From},${line_To}d" inputfilename > newfilename
sed 'linenumber, +countd' filename
$ cat t.txt
1
2
3
4
5
6
7
8
9
10
$ sed '4,+2d' t.txt
1
2
3
7
8
9
10
Try below code
sed '5,14d' inputfilename > newfilename
Cheers
Harish