$cat File1 File2 | perl -lane '$h{$F[0]} .= " @F[1..$#F]"; END { print join "\n",@h{qw(A M S T Z)}; }' Rahul 30 27 Apple Radha 45 Mango Ayaan 2 30 Sea Rayan 72 45 Train Sindh 4 90 Zebra $