TSV:如何连接领域2S如果场1是重复的 [英] TSV: how to concatenate field 2s if field 1 is duplicate

查看:111
本文介绍了TSV:如何连接领域2S如果场1是重复的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建了一个ANKI瑞典英语句子甲板从Creative通用许可tatoeba.org的内容。

I'm building a Swedish-English sentence deck for ANKI from the Creative Common licensed content of tatoeba.org.

请帮我转样品1到样品2(preferably在bash):

Please help me turning sample 1 to sample 2 (preferably in bash):

#sample1
a 1
a 2
b 3
c 4
c 5

#sample2
a 1<br>2
b 3
c 4<br>5

在现场1重复始终是后续。

Duplicates in field 1 are always subsequent.

感谢您!

推荐答案

使用的一种方法 AWK

awk 'p==$1{printf "<br>%s", $2;next}{if(p){print ""};p=$1;printf "%s", $0}END{print ""}' file
a 1<br>2
b 3
c 4<br>5

这篇关于TSV:如何连接领域2S如果场1是重复的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆