I have an input like:
1
2
3
4
5
6
7
8
And I'd like to retrieve only N first and M last lines from this input.
For example, if N is 2 and M is 4 I want the result to be:
1
2
5
6
7
8
Lines can overlap, so if N is 6 and M is 4 I want the output to be equal to my input.
I have tried using awk, with no luck:
cat input | awk "{if (NR<2 || NR>count - 4) {print}}"