Would like to compare second field from F11.txt and first field from F22.txt then Print match cases as "Available" and non match cases as "NotFound" if the field $4 (file F11.txt) is null, if the field $4 (file F11.txt) is not null then print the lines of F11.txt as it is.
Inputs:
F11.txt
a,10,zzz
b,20,zzz,yyy
c,50,zzz
F22.txt
10,yyy
20,yyy
30,yyy
40,yyy
Have tried the below command, Thanks sat for help.
awk -F "," 'NR==FNR{a[$1]=$0;next}{print $0 "," (a[$2]?"Available":"NotFound") }' f22.txt f11.txt
Got the below output
a,10,zzz,Available
b,20,zzz,yyy,Available
c,50,zzz,NotFound
where as b,20,zzz,yyy is match case but don’t want to override as "Available" as $4 is not null (empty)
Expected Output:
a,10,zzz,Avilable
b,20,zzz,yyy
c,50,zzz,NotFound