Awk command for multi-line regex
Posted on 2008-11-05
Assume an input file like this:
[TYPE description="description one"]
[TYPE description="description two"]
I need to assocate the description field of a [TYPE ] line with the name of the [name=] field which immediately precedes it in the file. In the above example, for instance, the name "n2" would be associated with "description one" and "n3" would be associated with "description two". There would be nothing associated with name "n1". There may be zero or more blank lines between the [name] line and the [TYPE] line.
The output (to stdout) would look like the following:
n1 "description one"
n2 "description two"
Is this possible with Awk?