1

so I know that to find the line number of the first occurrence of a pattern in a file I do:

zgrep -n -m 1 "pattern" big_file.txt.gz

but what If I want to skip the first 500K lines? (I can't decompress the file. It's too large.)

anubhava
  • 761,203
  • 64
  • 569
  • 643
user189035
  • 5,589
  • 13
  • 52
  • 112

1 Answers1

2

You may use this gzcat | awk command:

gzcat big_file.txt.gz |
awk 'NR > 500000 && /pattern/ {print NR ":" $0; exit}'
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 1
    On some Unix version `gzcat` is different from `zcat`. `gzcat` is for `.gz` files and `zcat` is for `.z` (zipped) files – anubhava Dec 08 '20 at 22:13