【发布时间】:2018-08-17 13:14:09
【问题描述】:
sed 新手并试图完成以下工作,但完全卡住了: 我试图在第二列中用 sed 替换模式。这种模式多次出现。
我有:
Gene1 GO:0000045^biological_process^autophagosome assembly`GO:0005737^cellular_component^cytoplasm
Gene2 GO:0000030^molecular_function^mannosyltransferase activity`GO:0006493^biological_process^protein O-linked glycosylation`GO:0016020^cellular_component^membrane
我想得到:
Gene1 GO:0000045,GO:0005737
Gene2 GO:0000030,GO:0006493,GO:0016020
所以去掉所有描述性部分并使用“,”作为分隔符。我选择使用 sed 是因为我认为可以轻松识别 ^ 和 ` 之间的模式。但相反,它删除了所有第一个 GO 术语。
代码:
sed -E 's/(^)'.+'(`)/,/g'
有人可以帮我吗?
【问题讨论】: