How do I transpose the following data
colA colB colC colD
val1 val2 val3 val4
val5 val6 val7 val8
So that it looks like this:
colA val1 val5
colB val2 val6
colC val3 val7
colD val4 val8
This data is tab delimited but It could also be comma delimited.
I can do this very easily in excel but I am wondering how to do it in bash using awk or something like that?
EDIT1
I can get it to work with spaces
$ cat testdata2_withspace.txt
colA colB colC colD
val1 val2 val3 val4
val5 val6 val7 val8
$ ./transpose3.sh testdata2_withspace.txt
colA val1 val5
colB val2 val6
colC val3 val7
colD val4 val8
but it is not doing the same with comma delimited files
$ cat testdata2.txt
colA,colB,colC,colD
val1,val2,val3,val4
val5,val6,val7,val8
$ ./transpose3.sh testdata2.txt
colA,colB,colC,colD val1,val2,val3,val4 val5,val6,val7,val8