【问题】
I have a large number of files with the same, tab-delimited format:
Column A Column B
Data_A1 Data_B1
Data_A2 Data_B2
Data_A3 Data_B3
These files all have the same number of lines.
I want to compile every file's Column B data into a single tab-delimited file. Right now, my best plan is to write a Perl script along these lines:
#!/usr/bin/perl
my $file = shift @ARGV;
my $ref = shift @ARGV;
open ( FILE, $file ); # FILE WITH FORMAT DESCRIBED ABOVE
while (<FILE>) {
chomp;
my @a = split("\t", $_);
push(@B, $a[1]);
}
close FILE;
my $counter = 0;
open (REF, $ref); # TAB-DELIMITED COMPILATION OF EVERY FILE'S COLUMN B
while (<REF>) {
chomp;
print "$_\t$B[$counter]\n";
}
close REF;
Then, write a BASH script that loops through all the files and saving the output of t