This is not an uncommon task. Here is one possible solution which you can alter to suit your particular requirements.
In reply to Re: Print a previous to previous of a matching line
by hippo
in thread Print a previous to previous of a matching line
by ag88
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |