column

Format text into aligned columns for cleaner terminal display and quick table-like output.

Category: Text Processing util-linux formatting tables terminal reports

Install

# Often already present
column --help

# RHEL / Alma / Rocky
sudo dnf install util-linux

# Debian / Ubuntu
sudo apt install bsdextrautils

# openSUSE
sudo zypper install util-linux

# Arch
sudo pacman -S util-linux

What it does

column takes plain text and lays it out into neat aligned columns. It is especially handy when you have space-separated, colon-separated, or tab-separated data and want something easier to read in a terminal without opening a spreadsheet.

How it works (mechanical)

  • Reads lines from a file or standard input.
  • Splits each line into fields using whitespace by default, or a chosen separator with -s.
  • Measures field widths across the input.
  • Reprints the data with padded spacing so columns align visually.
  • Can also format into rows or a table-like display depending on the options available on your system.

Quick Start

# Align a simple list into columns
printf "one two three\nfour five six\n" | column -t

# Format colon-separated data
printf "root:x:0:0\nbin:x:1:1\n" | column -s ':' -t

10 Practical Examples

  1. Align whitespace-separated text
    cat data.txt | column -t
  2. Format colon-separated records
    grep ':/bin/' /etc/passwd | column -s ':' -t
  3. Pretty-print CSV-like data with another separator
    printf "name,score,team\nAnn,88,Blue\nBob,91,Red\n" | column -s ',' -t
  4. Make mount output easier to read
    findmnt -r | column -t
  5. Inspect package or command output in table form
    lsblk | column -t
  6. Format a quick ad hoc report
    printf "host status load\nsrv1 up 0.12\nsrv2 down 0.00\n" | column -t
  7. View a tab-separated file cleanly
    column -t -s $'\t' report.tsv
  8. Show environment-style pairs
    printf "USER=alice\nSHELL=/bin/bash\nHOME=/home/alice\n" | column -s '=' -t
  9. Use in a pipeline with grep
    ps -eo user,pid,ppid,cmd | head -n 12 | column -t
  10. Reformat a hand-written list
    printf "red green blue\nyellow orange purple\n" | column -t

Notes & Gotchas

  • Whitespace input can be tricky. Multiple spaces are treated as separators, so original spacing is not preserved.
  • CSV is only basic here. For quoted CSV fields, use a real CSV tool rather than plain column.
  • Option sets vary by system. Different implementations may have slightly different flags.
  • Best for display, not storage. The aligned output looks nice for humans but is usually worse for machine parsing.
  • Long fields can stretch the display. Very wide text can make output hard to read on narrow terminals.

Historical Context

column has long been one of those quietly useful Unix text-formatting tools. It often ships as part of util-linux or related packages, and it remains valuable because terminal workflows still benefit from fast, readable alignment without a heavier reporting tool.

Modern Equivalent

  • mlr --icsv --opprint cat file.csv — much better for true CSV/TSV work
  • python -c '...' — useful when custom formatting is needed
  • csvlook — prettier display for CSV files when csvkit is installed

Related Commands

  • awk — process and reshape fields before display
  • printf — generate formatted text with precise control
  • cut — extract selected fields from lines
  • paste — merge lines side by side
  • csvtool — manipulate CSV data more safely
  • datamash — summarize and group tabular text data
  • nl — number lines in formatted output
  • comm — compare sorted files line by line