-2

I am trying to get data after the n:th line number.

I have a file with 1500 lines, but I want to print the data after 750 lines.

I tried head and tail, but couldn't get exactly what I wanted.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
Praveen
  • 15
  • 5
  • "print"? To the console? On a piece of paper? – DeeJayh Sep 20 '21 at 18:31
  • @DeeJayh It is customary to use the verb "print" to mean "to output". Would they want to actually get a hard copy of the output, then it would be trivial to pipe the result to `lp` or equivalent print spooler command. This does not change the what question is asking for. – Kusalananda Sep 20 '21 at 18:34
  • I thought tags will be checked, my bad. Trying in bash on linux server – Praveen Sep 20 '21 at 18:35

2 Answers2

5

You can use tail

tail -n +751 file

from man tail:

use -n +NUM to output starting with line NUM


Alternative using sed:

sed '1,750d' file

(delete everything from line 1 to 750)

pLumo
  • 22,231
  • 2
  • 41
  • 66
2

The awk command can be used with operators to specify the number record. In this case greater than (after) record 750.

awk 'NR>750' input_file_name

Detailed explanation

The awk command, or its distribution-specific counterparts like mawk in ubuntu, are usually available even in the most lean, base distrubitions. An awk program is a sequence of patterns and corresponding actions. The awk program 'NR>750' simply returns all records after line number 750.

Sourced from: https://stackoverflow.com/a/25678925/5387389

DeeJayh
  • 159
  • 5
  • 2
    I think you need `NR>750` as OP wants to print **after** line 750. Maybe that is why the downvote. However, that should be a comment rather than a downvote. – pLumo Sep 20 '21 at 18:47
  • @pLumo that could be right. I'll update the answer. – DeeJayh Sep 20 '21 at 18:52