2

For a file containing 20 lines, lines 6-10 can be printed using following command:

head -10 filename | tail -5

Can this exactly same thing be done without using 'head' and 'tail' commands ??

Please comment the link if similar question already exists.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
narendra-choudhary
  • 808
  • 2
  • 8
  • 15

1 Answers1

2

sed would work well here

seq 20 | sed '6,10!d'
6
7
8
9
10

You could use this as well: sed -n '6,10p'

Or awk, awk '6 <= NR && NR <= 10'

glenn jackman
  • 84,176
  • 15
  • 116
  • 168