Why we can't use python? It's the year 2015! python has been widely used in system administration long before, every linux distribution has python preinstalled, just like
sed. And for complex target like this, python code is much more readable and maintainable than
#! /bin/bash python - <<-EOF M = [line.split() for line in file("file.txt").read().splitlines()] for line in zip(*M): print " ".join(line) EOF
we can get things done with only 2 or 3 lines of python code! I highly doubt if
sed can do the same thing decently within 3 lines of code.