Looking for an awk one liner:
I have two files each with two columns
I need to print records where the first column match in both files and where the second file value column is > than the first file value column.
file1
AAAA 322
BBBB 322
DDDD 200
file2
AAAA 700
CCCC 400
DDDD 100
Looking for result
AAAA 700
Appreciate any help. So far I can match the column 1 but not sure how to calculate the second value column when it's >
awk 'NR == FNR{a[$1];next}$1 in a' file1.txt file2.txt
AAAA 700
DDDD 100
updated
I think I may have gotten it by reversing the file order and using:
awk 'FNR==NR{a[$1]=$2 FS $3;next}{ print $0, a[$1]}' file2.txt file1.txt|awk '$3 > $2' |awk '{print $1" "$3}'
AAAA 700