У меня очень большой набор входных данных, который выглядит примерно так:
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:...
...
Я хотел бы преобразовать это, чтобы вытащить имя метки (например, "foo"
) и заменить тег "<insert 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:...
...
Можно ли это сделать с помощью sed, awk или другого инструмента unix? Если да, то как я могу это сделать?