Your second solution could have been written as follows: perl -ne 'print ++$i . <> if /energy/' filenameperl -ne 'print if $prev; $prev = /energy/' file # Or with a counter perl -ne 'print ++$i, $_ if $prev; $prev = /energy/' file
--
John.
In reply to Re: A new question from the front line
by jmcnamara
in thread A new question from the front line
by bronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |