perl -ne '$a[($i+=1)%=5] = $_ if /foo/; END{print @a[$i+1..@a,0..$ +i]}' file
This reads all the way through the file so it will be less efficient than methods that read backwards through the file.
--
John.
In reply to Re: last $n lines that match a criteria
by jmcnamara
in thread last $n lines that match a criteria
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |