I want to remove some n lines from the end of a file. Can this be done using sed?
For example, to remove lines from 2 to 4, I can use
$ sed
This might work for you (GNU sed):
sed ':a;$!N;1,4ba;P;$d;D' file