Artificial intelligent assistant

awk compare two files and print first field in file 1 I have two files like this. file 1 1:apple 2:banana 3:pineapple 4:guava 5:orange and file 2 like this apple guava orange i just want to compare file 2 with file 1 and print the 1st field for the lines missing in file 2. Required output 3 4 Code I tried, > file1 <(cut -d: -f2 file2) but got the output as below 1a2,3 > banana > pineapple

How about an associative array lookup using Awk?


awk -F: 'NR==FNR {a[$1]; next} !($2 in a) {print $1}' file2 file1
2
3

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 505df2ba1d69feec5183862ec848b215