Script - columns to rows

Hi Everyone,

I have a file text.cvs, which is a file with columns from excel. The data are separeted with semicolon. The content of the file looks like
A B C D E F
1 3 3 4 3 3
2 2 1 2 5 2
5 6 1 1 2 1

Now I wish to write an script which writes the colums A, C and F in rows like
A 1 2 5
C 3 1 1
F 3 2 1
and save it in a new file newtext.cvs to be viewed in Excel.
Can you help me to write this script?

If you're already using excel, just copy and paste (special) with transpose.

I've posted only a simplified example. In the end I want to apply the script to transpose about 150 files with 30 columns each.

Try something like...

$ cat file1
A;B;C;D;E;F
1;3;3;4;3;3
2;2;1;2;5;2
5;6;1;1;2;1

$ gawk -v o='A|C|F' '
   BEGIN {FS=OFS=";"}
   {
      for (i=1; i<=NF; i++)
         a[NR,i]=$i
   }
   NF>m {m=NF}
   END {
      for (i=1; i<=m; i++)
         if (a[1,i] ~ o)
            for (j=1; j<=NR; j++)
               printf "%s%s", a[j,i], (j==NR?ORS:OFS)
   }' file1 > file2

$ cat file2
A;1;2;5
C;3;1;1
F;3;2;1

$

It works pretty well!! Thank you so much!!!