Show the diff in two files using awk

Hi,

How can i use AWK or any other commands to find the difference between 2 files.

File A

aaa
bbb
ccc
111
222

File B

aaa
ccc
111

Output

bbb
222

Will it work for csv file too?

Thank you.

If you are using bash:

comm -23 <(sort file_a) <(sort file_b)

can't compare line by line
as file Bis a subset of file A
all the content in file B can be file A.
So I want to see what are the lines in file A that is not in file B.

Thanks

---------- Post updated at 07:04 PM ---------- Previous update was at 06:49 PM ----------

sorry if the files are like this:
File A

abcd, 12334
bbb, 333
ccc, 555
ddd, 555

File B

abcd
ccc
ddd

Output

bbb

Thanks

Try:

comm -23 <(cut -d"," -f1 file_a|sort) <(sort file_b)

Hi we have two commands in unix to find the differende.

  1. cmp file1 file2
  2. diff file1 file2

try these..

awk -F, '{a[$1]++} END{for(row in a) if(a[row]==1) print row}' file*
1 Like

thanks alot..
:b:it seemed to work