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.

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
  • 85,964