Created
March 22, 2016 18:01
-
-
Save alexpreynolds/177fee79142ea42bcc36 to your computer and use it in GitHub Desktop.
Transpose matrix in awk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
for (i = 1; i <= NF; i++) { | |
a[NR,i] = $i | |
} | |
} | |
NF > p { p = NF } | |
END { | |
for (j = 1; j <= p; j++) { | |
str = a[1,j] | |
for (i = 2; i <= NR; i++) { | |
str = str"\t"a[i,j]; | |
} | |
print str | |
} | |
} |
Author
alexpreynolds
commented
Mar 22, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment