LoginSignup
13
8

More than 5 years have passed since last update.

重複していない行の抽出

Posted at

「sort」 と 「uniq -u」 がキーです。

単一のファイルから

baz.txt
A
B
A
B
C
> sort baz.txt | uniq -u
C

複数のファイルから

foo.txt
A
B
C
bar.txt
A
B
D
> sort foo.txt bar.txt | uniq -u
C
D

また、片方のファイルの「D」だけ抽出したい場合は、

foo.txtを重ねることで「C」を重複させる。

> sort foo.txt foo.txt bar.txt | uniq -u
D
13
8
0

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
13
8