In your updated second example you are in fact reading the entire file into memory (something the OP wanted to avoid), and creating the entire grep list in memory (at the same time), and then skimming the final N lines off that list. If the pattern occurs on every other line, you'll actually have the entire file plus half again in memory at once.
In reply to Re: Re: last $n lines that match a criteria
by Anonymous Monk
in thread last $n lines that match a criteria
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |