Link to home
Start Free TrialLog in
Avatar of bradjensen
bradjensen

asked on

Extract specific entires from a file based on unique tag identifier

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!

-Brad
SOLUTION
Avatar of Lee Wadwell
Lee Wadwell
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bradjensen
bradjensen

ASKER

Wonderful.  Both answers seem to work well.  Thanks!!