sorry, it actually should be like below - I'm bad.
#-----------------
BEGIN {
FS="#"
# to use a static thresholding
threshold=4
}
NR ==1 { prev=$0; next }
{
# to use 'dynamic' thresholding based on the length of the first field
# threshold=length(prev);
if( match($0, "^" substr(prev, 1, threshold) ".*"

== 1) {
print prev; print;
}
prev=$0
}
#---------------------
if( match($0, "^" substr(prev, 1, threshold) ".*"

== 1)
<From 'man nawk'>:
match(s,ere)
Return the position, in characters, numbering from 1
in string s where the extended regular expression ere
occurs, or zero if it does not occur at all.
</From 'man nawk'>
We're the 'match' returns '1' - in other words the 'beginning' of the string. We' are match-ing the ENTIRE current record [$0] against a dynamically built RE based on the content of the PREVIOUS record/line [prev]. The RE consists of:
"^" - beginning of the record
substr(prev, 1, threshold) - substring of the previous record [prev] starting at position 1 which is 'threshold' characters in length.
".*" - followed by ANY characters
If the entire 'match' reeturns the '1' [FIRST position of the current record, we print the previous record [prev] AND the current record ['print' - implicitely prints the entire current record].
hth
vlad
vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+