0

IN order to display from line 1 million, for 20 lines, I ended up with

head -1000020 myfile | tail - 20 

That works and I’ve wrapped in a function that does arithmetic for it. But I was wondering if there’s an existing bash or unix command for it.

Am on macOs, but happy knowing Linux for it too.

JL Peyret
  • 7,549
  • 2
  • 34
  • 48

1 Answers1

1

awk to the rescue!

$ awk -v n=1000000 'NR>n; NR==n+20{exit}' file

will exit early, useful if your file is very large.

karakfa
  • 62,998
  • 7
  • 34
  • 47