John Lawrence Aspden
John Lawrence Aspden

Reputation: 17470

How do I find all the lines that are in one file and not in another?

Say I got:

aaa
bbb
ccc

and:

aaa
ccc
ddd

and I would like:

bbb

How would I get it?

Upvotes: 1

Views: 265

Answers (2)

Ayyappa Boligala
Ayyappa Boligala

Reputation: 1096

Please try below command:

comm is used for Compare sorted files FILE1 and FILE2 line-by-line.

-23 suppresses column 2 and 3.

$ comm -23 fil1.txt fil2.txt  
bbb

Upvotes: 0

anubhava
anubhava

Reputation: 785146

Using grep -vf:

grep -vFxf file2 file1
bbb

Upvotes: 2

Related Questions