in reply to multicolumn extraction
Extract the 2nd and 3rd column, and write them to a new file:
use strict; use warnings; open my $APRI2_in, '<', 'path_to_infile.txt' or die $!; open my $out_fh, '>', 'path_to_outfile.txt' or die $!; while( <$APRI2_in> ) { my @columns = split /\t/, $_; print $out_fh "$columns[1]\t$columns[2]\n"; } close $APRI2_in; close $out_fh or die $!;
...or as a one-liner...
perl -plaF/\t/ -e '$_ = "$F[1]\t$F[2]"' infile > outfile
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: multicolumn extraction
by NetWallah (Canon) on Jun 03, 2012 at 18:06 UTC | |
Re^2: multicolumn extraction
by Kenosis (Priest) on Jun 03, 2012 at 16:30 UTC | |
by sauoq (Abbot) on Jun 03, 2012 at 17:05 UTC | |
by Kenosis (Priest) on Jun 03, 2012 at 17:15 UTC | |
by GrandFather (Saint) on Jun 03, 2012 at 22:33 UTC | |
by Kenosis (Priest) on Jun 03, 2012 at 23:00 UTC | |
by sauoq (Abbot) on Jun 04, 2012 at 20:08 UTC |