Personally, I might consider doing this in a scripting language, as it looks like it could get a bit complex. Also, the format is pretty clunky... is every record 5 lines in the same order, separated by that "----------------"? Something like CSV would be so much nicer...
i.e. how much heavy parsing do you need to do, and how much can you do by just pulling each record out of the file and then using grep or head/tail and awk?
Specific to your question - awk doesn't grep for something. grep greps for something. I'm sure there are conditionals in awk, but I've never used them. The ideal way I would do this, if the file is fixed-format, is to used sed to replace every newline with a space and replace every one of those "-----------" with a newline, ending up with one record per line. then just use awk to print the right fields.
|