Rows to Column

I have a tab delimited file like this:

1   2   3   4   5   6 
7   8   9   10  11   12 
13  14  15  16   17   18



I want it to look like:

1   7    13
2   8    14
3   9    15
4   10   16
5   11   17
6   12   18

I was thinking reading line by line into it's own array with perl, printing \n, and then pasting/appending columns next to each other. But there must be a faster way, can't awk do this easily?

vgersh99 has a handy awk script for that.

I don't have nawk on my commandline. using regular awk gives me a weird output

$
$
$ cat f24
1    2   3   4     5    6
7    8   9   10   11   12
13  14  15   16   17   18
$
$
$
$
$ perl -ane '@{$y[$.-1]} = @F;
             END {
               for ($i=0; $i <= $#{$y[0]}; $i++) {
                 for ($j=0; $j <= $#y; $j++) {
                   print $y[$j]->[$i], "\t";
                 }
                 print "\n";
               }
             }
            ' f24
1       7       13
2       8       14
3       9       15
4       10      16
5       11      17
6       12      18
$
$
$

tyler_durden