in reply to Re: Content of one file to another file if a filed matches
in thread Content of one file to another file if a filed matches

Very nice. I didn't know about the autosplit, -a, option. One small improvement, I added the letter at the beginning of each line as requested by the OP. I'm running this on a Windows server so I had to adjust the quotes to work.

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

Replies are listed 'Best First'.
Re^3: Content of one file to another file if a filed matches
by trippledubs (Deacon) on Mar 09, 2017 at 19:35 UTC
    thanks, agreed map is better

      Your approach of appending the value on key collisions was new to me. I've been trying to improve my one-liner skills so this was a good chance to practice figuring out how it worked.