001、
[root@PC1 test2]# ls a.txt [root@PC1 test2]# cat a.txt 01 aa 02 03 04 aa 05 06 07 bb 08 09 10 bb 11 12 13 aa 14 15 16 bb 17 18 19 cc 20 21 22 cc 23 24 25 bb 26 27 28 ee 30 [root@PC1 test2]# awk '{OFS = "\t"; if(!($2 in ay1)) {ay1[$2]++; tmp = $2}; if($2 in ay1 && tmp != $2) {ay1[$2]++};tmp = $2; $2 = ay1[$2]"_"$2; print $0}' a.txt 01 1_aa 02 03 04 1_aa 05 06 07 1_bb 08 09 10 1_bb 11 12 13 2_aa 14 15 16 2_bb 17 18 19 1_cc 20 21 22 1_cc 23 24 25 3_bb 26 27 28 1_ee 30
。
标签:aa,test2,bb,cc,测试,txt,ay1 From: https://www.cnblogs.com/liujiaxin2018/p/18236340