Skip to content

Instantly share code, notes, and snippets.

@mdunsmuir
Created August 21, 2014 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdunsmuir/0ebdca2bb6c25e79773f to your computer and use it in GitHub Desktop.
Save mdunsmuir/0ebdca2bb6c25e79773f to your computer and use it in GitHub Desktop.
transpose a file shell one-liner
#!/bin/sh
ruby -e 'lines=IO.readlines(ARGV.shift);l=lines.map(&:length).max;puts lines.map{|s|sprintf("%-#{l}s",s.strip).chars}.transpose.map(&:join).join("\n")' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment