我有以下文件:
petro,36262 artur,946034 alex,12345 alex,99999 artur,111111111
我需要的是用基于第一列作为主键的底部字符串替换上部字符串,所以最后它看起来像:
petro,36262 alex,99999 artur,111111111
第一列可以包含空格或数字。
由于
答案 0 :(得分:1)
这是一种方法:
$ awk -F, '{a[$1]=$2} END{for (name in a)print name","a[name]}' file
alex,99999
artur,111111111
petro,36262
线条以任意顺序出现。如果您有首选订单,则需要一些额外的代码。