题解 | #第二列是否有重复#
第二列是否有重复
https://www.nowcoder.com/practice/61b79ffe88964c7ab7b98ae16dd76492
#!/bin/bash read -a arr while [ ${#arr[@]} -eq 2 ] do sum=$((${arr[0]} + ${arr[1]})) echo $sum read -a arr done awk ' BEGIN{} { if($2 in arr){ arr[$2]+=1 }else{ arr[$2]=1 } } END{ PROCINFO["sorted_in"]="@ind_str_asc" for(i in arr){ if(arr[i] > 1){ print(arr[i],i) } } } ' nowcoder.txt | sort -k 1 exit 0