perl -e 'for(@ARGV){open FILE,$_;chomp($a[$.-1].=$_)while;close FILE}$,=$/;open FILE,">out";print FILE@a' A B C