Suppose you have a file:
12
234
bingo
1
bingo
572
22
How to print the file starting from the 2-nd (or N-th) occurrence of “bingo”? Like cat, but only part of the file. Like tail +3, but the line number cannot be hardcoded. The output should be:
bingo
572
22
As a terrible hack, I came up with this to get the 2-nd occurrence and below:
grep --after-context=999999999 'bingo' file.txt | tail +2 | grep --after-context=999999999 'bingo'
But this is terribly inefficient, and doesn’t scale well to the N-th occurrence.