输入文件
tbname id department
xyz 20 cic
xyz 21 csp
xyz 22 cpz
abc 25 cis
abc 26 cta
abc 27 tec
输出应该是这样的..
tbname id department
xyz 20 cic 1
xyz 21 csp 2
xyz 22 cpz 3
abc 25 cis 1
abc 26 cta 2
abc 27 tec 3
所有字段均由标签分隔
答案 0 :(得分:0)
在awk中真的微不足道:
$ awk 'NR>1{$0=$0"\t"++a[$1]}1' file
tbname id department
xyz 20 cic 1
xyz 21 csp 2
xyz 22 cpz 3
abc 25 cis 1
abc 26 cta 2
abc 27 tec 3