001、
(base) [b20223040323@admin1 test]$ ls a.txt (base) [b20223040323@admin1 test]$ cat a.txt ## 测试数据 a 88 a 76 b 88 c 10 b 777 c 200 a 87 c 150 a 34 b 25 a 66 ## 输出第一列中每一类别中值最大的项 (base) [b20223040323@admin1 test]$ awk '{if (!($1 in ay)) {ay[$1] = $2}else{if($2 > ay[$1]){ay[$1] = $2}}}END {for (i in ay) {print i, ay[i]}}' a.txt a 88 b 777 c 200
。
标签:admin1,ay,88,test,awk,Linux,类别,txt From: https://www.cnblogs.com/liujiaxin2018/p/17999580