Last active
April 30, 2018 19:18
-
-
Save DSuveges/f269a5bc9c2afbac50fb483e2749caf7 to your computer and use it in GitHub Desktop.
A short shell script to transpose 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
#!/bin/bash | |
awk ' | |
{ | |
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 | |
} | |
}' $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment