Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
1 1 1 2 2 2 3 3
これらの数字を含むファイルがあるとしましょう。これらの数字をこのように数えたいと思います
(数):(出現)
1:3 2:3 3:2
シェルスクリプトでこれを行うにはどうすればよいですか?
あなたはこれを使うことができます
sort a.dat | uniq -c | awk '{print $2, ":", $1}'
どうしても空白が気になるなら
sort a.dat | uniq -c | awk '{print $2":"$1}'