LinuxCommandLibrary

column

Format data into aligned columns

TLDR

Format the output of a command for a 30 characters wide display

$ printf "header1 header2\nbar foo\n" | column [[-c|--output-width]] [30]
copy

Split columns automatically and auto-align them in a tabular format
$ printf "header1 header2\nbar foo\n" | column [[-t|--table]]
copy

Specify the column delimiter character for the --table option (e.g. "," for CSV) (defaults to whitespace)
$ printf "header1,header2\nbar,foo\n" | column [[-t|--table]] [[-s|--separator]] [,]
copy

Fill rows before filling columns
$ printf "header1\nbar\nfoobar\n" | column [[-c|--output-width]] [30] [[-x|--fillrows]]
copy

SYNOPSIS

column [-c WIDTH] [-s SEP] [-t] [-x] [-N] [FILE]...

PARAMETERS

-c, --columns=WIDTH
    Format output WIDTH characters wide (0 uses input width)

-s, --separator=SEP
    Field separator (default: whitespace; use - for tab)

-t, --table
    Produce aligned table output adjusted to terminal width

-x, --fill
    Fill columns completely before starting new ones

-N, --header
    Treat first line as header (exclude from column sizing)

-h, --help
    Display usage help

-V, --version
    Print version information

DESCRIPTION

column is a versatile utility for rearranging text input into evenly spaced columns, ideal for displaying lists or tabular data readably on terminals.

It processes lines from files or stdin, splitting fields by whitespace (or custom separator), measures field widths, and packs them into columns fitting the terminal width or specified size.

Default mode balances columns dynamically. Use -t for table-style output with separators and padding. -x fills columns fully before new ones, mimicking traditional behavior. Custom separators like -s : handle colon-delimited files such as /etc/passwd.

-N preserves the first line as header without including it in width calculations. Output width can be fixed via -c, overriding terminal detection.

Examples: cat /etc/passwd | column -t -s : creates a neat user table; ls -l | column -t aligns file listings.

Lightweight and fast, it's perfect for shell scripts and one-liners needing quick formatting without heavy tools.

CAVEATS

Splits on whitespace sequences by default; table mode (-t) ignores -x and relies on $COLUMNS or ioctl(3); limited multi-byte character support in older versions; no built-in sorting.

EXAMPLES

cat /etc/passwd | column -s: -t
Formats passwd into table.

ps aux | column -t
Aligns process list.

seq 1 36 | column -c 40
Forces 40-char width.

HISTORY

Part of util-linux suite since ~1994 (from 4.3BSD origins); enhanced in util-linux 2.20+ with -t and -N for better table handling; widely used in Linux distros for ad-hoc formatting.

SEE ALSO

pr(1), paste(1), expand(1), cut(1)

Copied to clipboard