A (readable) perl version is:
#!/usr/bin/perl
use strict;
my %lookup;
open FILE, "File1.csv" or die "Couldn't open file: $!";
while (<FILE>){
chomp;
my ($left, $right) = split(',', $_);
$lookup{$right} = $_;
}
close FILE;
open FILE, "File2.csv" or die "Couldn't open file: $!";
open OUT_FILE, ">File3.csv" or die "Couldn't open file: $!";
while (<FILE>){
chomp;
if (exists ($lookup{$_})) {
print OUT_FILE "$lookup{$id}\n";
}
}
close FILE;
close OUT_FILE;
Store the code e.g. as so_33254185.pl and call
$>perl so_33254185.pl
I know you asked for pure shell solution, but maybe this allows you to improve it yourself.