Created
March 19, 2014 13:16
-
-
Save nstjhp/9641401 to your computer and use it in GitHub Desktop.
Transpose a tab separated file using AKW from a SO answer
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
#!/usr/bin/awk -f | |
# http://stackoverflow.com/a/1729980/3275826 | |
# Make sure this directory/file is in your $PATH | |
# then call as transpose.awk fileName | |
{ | |
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" "a[i,j]; | |
} | |
print str | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment