I have two files (let's say a.txt
and b.txt
), both of which has a list of names. I have already run sort
on both the files.
Now I want to find lines from a.txt
which are not present in b.txt
.
(I spent lot of time to find the answer for this question, so documenting it for future reference)
ベストアンサー1
使用すべきコマンドはdiff
、comm
/usr/bin/comm -23 a.txt b.txt
デフォルトでは、comm
3 つの列を出力します。左のみ、右のみ、両方-1
、およびスイッチ-2
は-3
これらの列を抑制します。
-23
だから、右のみそして両方列には、最初の (左側の) ファイルにのみ表示される行が表示されます。
両方に現れる行を見つけたい場合は、 を使用します-12
。左のみそして右のみ列が表示され、両方カラム。