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.

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)
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.