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.
Linuxマシンの多くのシェルスクリプトで「uniq -d -c file」を使用しましたが、機能します。私のMAC(開発者ツールがインストールされたOS X 10.6.7)では、動作していないようです:
$ uniq -d -c testfile.txt usage: uniq [-c | -d | -u] [-i] [-f fields] [-s chars] [input [output]]
誰かがこれをチェックできるといいですね。
まあ、それはUsageメッセージの中にあります。2 つではなく、 1 つ[ -c | -d | -u]の可能性を使用できることを意味します。
Usage
[ -c | -d | -u]
OSX は BSD に基づいているため、ここで確認できます。または、Ignacio のおかげで、Apple 固有のものはこちらで確認できます。
同様の出力を実現したい場合は、次を使用できます。
do_your_thing | uniq -c | grep -v '^ *1 '
これにより、カウントが 1 の合体行がすべて取り除かれます。
この awkソリューションを試すことができます
awk
awk '{a[$0]++}END{for(i in a)if(a[i]>1){ print i ,a[i] } }' file