sql で いちいち group by count やるの面倒
テーブル作ってー
create table words ( word text ) ;
データ投入してー
insert into words values ( "aaaa" ) ; ..
集計して
select word, count(*) as from words group by word order by cnt desc ;
え?、、表計算?それはちょっと考えたくない
コマンドで楽勝
テキスト中の重複文字数をカウントするに uniq -c を使える。
cat - | sort | uniq -c | sort -r -n
最後に、ソートで、降順に出力すれば終わり。
実際にやってみるとこんな感じ
ruby -e 'list = ("a".."z").map{|e| e* 5 };1000.times{ puts list[rand(list.size)] }' | sort | uniq -c | sort -n -r
54 iiiii
51 kkkkk
49 wwwww
47 rrrrr
46 ggggg
45 vvvvv
45 uuuuu
44 zzzzz
42 ccccc
41 sssss
40 ddddd
38 yyyyy
38 ttttt
37 aaaaa
36 hhhhh
36 eeeee
35 ppppp
35 lllll
35 fffff
34 ooooo
34 mmmmm
33 xxxxx
33 nnnnn
29 jjjjj
22 bbbbb
21 qqqqq
やっぱりコマンド最強。