awk 2 files

Hello
I have 2 files

file1

/tmp/xxx
/tmp/yyy
/tmp/ccc

file2

/tmp/aaa
/tmp/ccc
/tmp/yyy

I would like have output

/tmp/aaa - NO 

So check all entries from file1 in file2 and if entry from file2 not exist in file1 display it.

Can someone help write code in AWK?

Are the input files sorted?

sort file1 >file1.tmp
sort file2 >file2.tmp
diff file1.tmp file2.tmp
awk 'FNR==NR {f1[$1];next} !($1 in f1)' file1 file2

With a recent bash that provides "process substitution", try

comm -13 <(sort file1) <(sort file2)
/tmp/aaa
#/bin/bash
for i in `cat file2`
do
     grep -w $i file1 > /Dev/null 2>&1 || echo $i
done

---------- Post updated at 03:40 PM ---------- Previous update was at 03:39 PM ----------

Some auto ajusts...