Created
October 13, 2015 20:36
-
-
Save indraniel/9413bd93b0db462de914 to your computer and use it in GitHub Desktop.
transpose a text table
This file contains 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
#!/usr/bin/awk -f | |
# taken from: http://stackoverflow.com/questions/1729824/transpose-a-file-in-bash | |
{ | |
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment