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 4 3 3 2
ファイルに数字が現れる回数を数えたい。出力ファイルは次のようになります。
1 2 2 1 3 2 4 1
ありがとう
この行を試してください:
awk '{a[$0]++}END{for(x in a)print x,a[x]}' file
awk '{tot[$0]++} END{for (n in tot) {print n,tot[n]}} ' numbers