sort users begining with each letter of the alphabet from greatest to least occurence
hi i was just wondering how to sort users beginning with each letter of the alphabet from greatest to least occurrence?
i have something like this : sort -t, -k1,2n -k4,5rn /etc/passwd but how would i specify how to determine which letter of the alphabet is being called? my output should be something like : c => 3 b => 2 d => 2 a => 1 ... z => 0 some help would be much appreciated |
Code:
awk -F ":" ' |
thanx a lot ghostdog74 works perfectly!
|
question : code from ghostdog74 works fine but how do i sort it from greatest to least occurrence?
i tried : awk -F ":" ' { fchar = substr($1,0,1) ++cnt[fchar] } END{ for (i in cnt) { print i "=>" cnt[i] | "sort" } }' /etc/passwd |grep -nr but it just reverses the order not the sorting from greatest to least. any idea? |
Quote:
please give me some hints on how to sort this code in order that it displays from greatest occurrence to least |
Hi,
This should work: Code:
nawk -F ":" ' Code:
b => 5 Hope this helps. |
All times are GMT -5. The time now is 12:19 AM. |