
Linuxで重複している行を1行にまとめます。
ソートされていないファイルで試す!
ソートされていないファイルでは、重複している行を1行にまとめることはできません。
$ cat test.txt server01 server02 server04 server02 server03 $ uniq test.txt server01 server02 server04 server02 server03
ソートして重複している行を1行にまとめる!
今度は、ソートして重複している行を1行にまとめます。
$ cat test.txt | sort | uniq server01 server02 server03 server04
おわりに
Linuxには、重複行まとめるコマンドがあることを覚えておきましょう。
関連記事
関連書籍(Amazon)