Hello,
I have a file which contains groups of fields. These groups are separated by a blank line, to form a logical record.
Each line consists of a field-value pair.
If want to find all records where field 'd' has a value of '4' and if it does, I want the value of field 'a' (from the same record).
Here's an example input file:
Quote:
a 1
b 2
c 3
d 4
a 2
b 1
d 6
b 3
a 6
c 2
c 2
d 4
a 9
c 3
d 4
a 3
d 4
a 6
I want to end up with a file containing:
Import things to nore about the input file are a) the number of records varies, b) not all records contain a 'd' field, c) not all records contain a 'a' field, e) fields can be in any order within a record.
I think the answer will be to use AWK but I have very little knowledge of AWK and have only used it for very basic things.
The OS is Sun 5.8 by the way.
Help would be greatly appreciated.
Thanks.