Extract specific entires from a file based on unique tag identifier
Posted on 2004-04-14
I have several files which I need to extract information from. Each of these files has 'records' in them which have multiple lines per record. Each record is seperated by a blank line. Each line in the file consists of a 'tag' field and a 'value' field, seperated by a "=" character.
Some of the records have a tag called "super_pid", where other records don't. However, all records contain a tag called "IP_address". If the record contains a "super_pid", then the "IP_address" tag will always be 2 lines after the "super_pid" line.
For every record that contains a "super_pid", I need to print out the "super_pid" value with the corresponding record's "IP_address" value, on the same line, seperated by a comma.
I would like to have this done in awk or some sort of loop, as it will be imbedded as a funtion in a seperate ksh script.
Thanks in advance!