Skip to content

Instantly share code, notes, and snippets.

@DSuveges
Last active April 30, 2018 19:18
Show Gist options
  • Save DSuveges/f269a5bc9c2afbac50fb483e2749caf7 to your computer and use it in GitHub Desktop.
Save DSuveges/f269a5bc9c2afbac50fb483e2749caf7 to your computer and use it in GitHub Desktop.
A short shell script to transpose table
#!/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