I have a very large input set that looks something like this:
Label: foo, Other text: text description...
<insert label> Item: item description...
<insert label> Item: item description...
Label: bar, Other text:...
<insert label> Item:...
Label: baz, Other text:...
<insert label> Item:...
<insert label> Item:...
<insert label> Item:...
...
I’d like to transform this to pull out the label name (e.g. "foo") and replace the tag "<insert label>" on the following lines with the actual label.
Label: foo, Other text: text description...
foo Item: item description...
foo Item: item description...
Label: bar, Other text:...
bar Item:...
Label: baz, Other text:...
baz Item:...
baz Item:...
baz Item:...
...
Can this be done with sed or awk or other unix tool? If so, how might I do it?
One solution using
sed:Content of
script.sed:Content of
infile:Run it like:
And result: