in reply to Shell Script Woes

Make the assumption that the string won't wrap 3 or more lines (though unlikely)
I am a bit confused by this. It looked as though "filename" contained a list of string or re's to match. It seems as though the remaining files contain lines of data. I guess what this means is that the string to match could be very long: possibly 3+ lines. Is that correct?

Some ideas that might get you going:

HTH, --traveler