Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just want an easy way to columnize output to the terminal.

  • Don't care about colors. (Well, actually I do quite a bit! But there is the awesome, easy-to-use ANSI Color for that.)
  • Shell scripts preferred, but anything easy-to-use will do.
  • Flexible solutions preferred, but the simple case I'd love to solve is just looking through text line-by-line, looking for the first occurrence of a separator (say, the equals sign, or maybe a comma), and separate everything on either side of that character into its own column.
share|improve this question
up vote 8 down vote accepted

Use the column command:

rpinson@rpinson:~$ mount | column -t
/dev/sda1         on  /                         type  ext3                   (rw,errors=remount-ro)
proc              on  /proc                     type  proc                   (rw,noexec,nosuid,nodev)
none              on  /sys                      type  sysfs                  (rw,noexec,nosuid,nodev)
none              on  /sys/kernel/debug         type  debugfs                (rw)
none              on  /sys/kernel/security      type  securityfs             (rw)
none              on  /dev                      type  devtmpfs               (rw,mode=0755)
none              on  /dev/pts                  type  devpts                 (rw,noexec,nosuid,gid=5,mode=0620)
none              on  /dev/shm                  type  tmpfs                  (rw,nosuid,nodev)
none              on  /var/run                  type  tmpfs                  (rw,nosuid,mode=0755)
none              on  /var/lock                 type  tmpfs                  (rw,noexec,nosuid,nodev)
none              on  /lib/init/rw              type  tmpfs                  (rw,nosuid,mode=0755)
binfmt_misc       on  /proc/sys/fs/binfmt_misc  type  binfmt_misc            (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon  on  /home/rpinson/.gvfs       type  fuse.gvfs-fuse-daemon  (rw,nosuid,nodev,user=rpinson)
share|improve this answer
That was easy!! – Linker3000 Jun 8 '11 at 14:47
But beautiful :D – Pitto Jun 8 '11 at 16:33
Holy crap …that WAS easy! ☺ I can’t believe I haven’t heard of this awesome little program before. You, @Raphink , rock. – Zearin Jun 10 '11 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .