linux 中输出一列数据中最大值的行号
001、
[root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt 5 8 2 7 3 [root@pc1 test1]# awk '{if(NR == 1) {idx = NR; value = $1}; if($1 > value) {idx = NR; value = $1}} END {print idx}' a.txt 2

。
001、
[root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt 5 8 2 7 3 [root@pc1 test1]# awk '{if(NR == 1) {idx = NR; value = $1}; if($1 > value) {idx = NR; value = $1}} END {print idx}' a.txt 2

。