1

Assume I have a file with about 10000 lines.

How can I print 100 lines, starting from line 1200 to line 1300?

polym
  • 10,672
  • 9
  • 41
  • 65
Alireza Fallah
  • 709
  • 5
  • 14
  • 25

1 Answers1

4

With awk this would be awk 'NR >= 1200 && NR <= 1300'

with sed: sed -n '1200,1300 p' FILE

with head and tail: head -n 1300 FILE | tail -n 100

so many options, so many answers on stackexchange :)

b13n1u
  • 524
  • 3
  • 7
  • I suggest that this page be fixed. The page question is "How to echo from specific line of a file to another specific line" yet the answer is a non-sequitur regarding how to print a range of lines. – unifex Jun 17 '23 at 19:32
  • Answer to question as asked: Insert line 3 from a file named things.txt to line 6 of a file named numbers.txt using head tail and ex: LINE=$(head -3 things.txt |tail -1) ex numbers.txt <numbers2.txt – unifex Jun 17 '23 at 19:33