When Jim Osborn asked,
O> How do I search the first N lines of the mail body for a regexp?
I suggested, at first,
T> If N is fixed and not too great, you could try this (it's ugly, I know):
T>
T> :0B
T> * ^^.*(^.*)?(^.*)?(^.*)?(^.*)?regexp
T>
T> where "(^.*)?" appears N-1 times.
This approach might be easier to type, proofread, and edit if N changes.
Remember that procmail does maximum matching to the right of \/, so we'll
get all N lines if there are N or more lines yet whatever there is with no
error if there are fewer than N:
:0B # exactly N (not N-1) occurrences of ".*$?"
* ^^\/.*$?.*$?.*$?.*$?.*$?.*$?.*$?
{ TOPLINES=$MATCH }
:0
* TOPLINES ?? regexp
action Jim wants
and if you don't mind an extra process,
LINEStoSCAN=N # fill in the number
:0b
TOPLINES=|head -$LINEStoSCAN # sed -${LINEStoSCAN}q if you don't have head
:0
* TOPLINES ?? regexp
action Jim wants