Update: It still did not figured it out, please have a look:
when I modify test main file to:
one:111:222:333 fiv:333:222:333 two:123:234:500 ten.233:422:452 And run this awk command:
$ awk -F':' -vf=main 'FILENAME==f{m=$0};FILENAME!=f&&$2~/[0-9]+/{if ($2~/[0-9]+/&&(!($1 in a) || $3 > a[$1])) { a[$1] = $3; b[$1] = $0 } next;}{if (($1 in a) && (a[$1] > $3)){ print b[$1]":updated:"m; delete b[$1] } else print; }' file* main thr:-:234:232 one:111:222:333 fiv:999:500:232:updated:fiv:333:222:333 two:123:234:500 ten.233:422:452 So output is wrong because of thr line which should not be on output as thr is not in main file
I modified command adding additional condition else if($1 in a) {print}; but then it does not print line beginning with "ten" in main file:
$ awk -F':' -vf=main 'FILENAME==f{m=$0};FILENAME!=f&&$2~/[0-9]+/{if ($2~/[0-9]+/&&(!($1 in a) || $3 > a[$1])) { a[$1] = $3; b[$1] = $0 } next;}{if (($1 in a) && (a[$1] > $3)){ print b[$1]":updated:"m; delete b[$1] } else if($1 in a) {print}; }' file* main one:111:222:333 fiv:999:500:232:updated:fiv:333:222:333 two:123:234:500 I'll appreciate any help very much.
Awk is really very awesome, unfortunately I being not a programmer can't figure it out on my own yet.