I have 3 files, as below:
*File1:*
5372,5372,0,0,,1,0,1,1,0,1,0,0,0,0,0,0,1107,1107,,1.620000,1,2015-08-12,,,,,,,,,,,,,,,,,,,,,,,,
2110,2110,0,0,,0,0,1,0,0,0,0,1,1,1,1,1,1601,1601,,9.500000,1,2015-05-29,,,,,,,,,,,,,,,,,,,,,,,,
6900,6900,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,1107,1107,,1.369000,1,2025-09-23,,,,,,,,,,,,,,,,,,,,,,,,
8755,8755,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,1107,1107,,3.232000,1,2025-05-22,,,,,,,,,,,,,,,,,,,,,,,,
*File2:*
5372,4074,,,,,2,,,
2110,4100,,,,,0,,,
6900,5246,,,,,0,,,
8755,5270,,,,,0,,,
*File3:*
2187,2500
2188,1500
4227,2000
5270,3000
Noting that the `NF` for *File1*, *File2* and *File3* is `47`, `10` and `2` respectively.
The need is to check the records from File2 that have $4=2025, for these records we need to match $1 from File2 with $1 from File1, and for the matched records, change the value of $21 in File1 to be $21=$21*1000
then compare it with $2 of File3, if it is equal or greater print $0
The expected output for above files:
8755
I have tried the following code:
awk -F"," '{
if (NF==47) {
if ($23 ~ /2025/) {$21=$21*1000}
{A[$1]=$0}
} else {
if (NF==10) {
if (A[$1]==$0) {B[$1]=$0}
}
{if (NF==2) {
B[$1]==$0 && $21>=$2
}
{print $0}
}
}'
but the outputs always were empty records
Please Advise.