How can I print from the fourth to the second last line using sed
command?
2 Answers
sed -e '4,$!d' -e '$d'
Ex.
$ printf 'Line %d\n' {1..10} | sed -e '4,$!d' -e '$d'
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Try this,
sed -e '1,3d;$d' file
1,3d
to delete first 3 lines.$d
to delete last line.