I have to count values in first column of a file for which the second column occurrences are the same , using Unix.12,abn23,abn45,hh52,hh89,mm89,mmMy output should be something like this:35,abn97,hh178,mmAny help?
Count values in first column where second column occurrences are the same in UNIX
bash;text processing
With awk:$ awk -F, -vOFS=, 'NF{a[$2]+=$1}END{for(i in a) print a[i],i}' file | sort -n35,abn97,hh178,mm