4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

#Linux の uniq コマンドが効かない? sort と組み合わせないとだめだよ!

Last updated at Posted at 2019-05-11

ABA をユニークにしてくれない

[root@7c3532dbdfc1 /]# echo -e "A\nB\nA" | uniq
A
B
A

ABB はユニークにしてくれる

[root@7c3532dbdfc1 /]# echo -e "A\nA\nB" | uniq
A
B

sort してから uniq しよう

[root@7c3532dbdfc1 /]# echo -e "A\nB\nA" | sort | uniq
A
B

こんな仕様ある?

罠すぎるでしょ。

また Mac というか BSD版 てめーの仕業か!

と最初は思ったけど違ったよ。

Ref

uniqコマンドについて詳しくまとめました 【Linuxコマンド集】

image

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?