【发布时间】:2012-03-08 18:22:31
【问题描述】:
我有一个非常大的输入集,看起来像这样:
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 工具来完成吗?如果是这样,我该怎么做?
【问题讨论】: