column — Format Input into Columns and Tables
Practical guide to column — columnate lists, build aligned tables from delimited data and format command output for better readability in the terminal.
column formats input into clean, aligned columns or tables – ideal for making messy command output or delimited data readable in the terminal. In its simplest form it spreads a list across several columns that fill the terminal width; with -t it detects the number of columns automatically and aligns a proper table. With -s you set the input delimiter, with -o the output delimiter, and with -N, -H, -O or -R you name, hide, reorder and align individual columns. The modern util-linux version can even emit JSON. Note that column varies between distributions and versions – the options shown here assume a recent util-linux.
Basic Usage
column <file> — Fill columns before rows. Formats input into multiple columns to fill the terminal width.
column /etc/shells<command> | column — Columnate command output to fill the terminal width.
echo -e 'one\ntwo\nthree\nfour\nfive\nsix' | columncolumn -x <file> — Fill rows before columns (left to right, then next row).
ls /usr/bin | column -xcolumn -c <width> <file> — Set output width in characters instead of using terminal width.
column -c 40 names.txtTable Mode
column -t <file> — Create a table. Determine the number of columns and align them.
column -t /etc/fstabcolumn -t -s '<sep>' <file> — Create a table using a custom input delimiter.
column -t -s ',' data.csvcolumn -t -s ':' <file> — Create a table from colon-separated data.
column -t -s ':' /etc/passwdcolumn -t -s $'\t' <file> — Create a table from tab-separated data.
column -t -s $'\t' data.tsvcolumn -t -o '<sep>' <file> — Set the output column separator (default: two spaces).
column -t -s ',' -o ' | ' data.csvColumn Selection & Naming
column -t -N <names> <file> — Set column names as comma-separated list. Adds a header row.
column -t -N 'Name,Age,City' -s ',' data.csvcolumn -t -H <columns> <file> — Hide specified columns from output (by name or 0-based index).
column -t -s ':' -N 'User,Pass,UID,GID,Info,Home,Shell' -H Pass /etc/passwdcolumn -t -O <columns> <file> — Reorder columns in the specified order.
column -t -s ',' -O 'City,Name,Age' data.csvcolumn -t -R <columns> <file> — Right-align specified columns (by name or 0-based index).
column -t -s ',' -R 'Price,Amount' sales.csvAdvanced Table Options
column -t -l <count> <file> — Limit the number of columns in table mode.
column -t -l 3 data.txtcolumn -t -e <file> — Do not ignore empty lines in table mode.
column -t -e data.txtcolumn -t -n <file> — Set the table name (only takes effect with JSON output -J; no visible effect in plain text mode).
column -t -n -N 'PID,User,Command' -s ',' procs.csvcolumn -t -W <columns> <file> — Wrap text in specified columns if it exceeds terminal width.
column -t -s ',' -W 'Description' items.csvJSON Output
column -t -J <file> — Output table as JSON array of objects (requires -N or header row).
column -t -s ',' -J -N 'Name,Age,City' data.csvcolumn -t -J -n <name> <file> — Set the JSON array name in output.
column -t -s ',' -J -n 'users' -N 'Name,Email' users.csvPipelines
<command> | column -t — Align whitespace-separated command output into a clean table.
mount | column -t<command> | column -t -s '<sep>' — Create aligned table from delimited command output.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | column -tprintf '%s\n' <items> | column — Format a list of items into columns for display.
printf '%s\n' red green blue yellow orange purple | column<command> | column -t -s $'\t' — Format tab-separated output into an aligned table.
docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' | column -t -s $'\t'Common Patterns
cat /etc/passwd | column -t -s ':' — Display /etc/passwd as a readable aligned table.
cat /etc/passwd | column -t -s ':'(head -1 <file> && tail -n +2 <file> | sort) | column -t -s ',' — Sort a CSV file (keeping header) and display as aligned table.
(head -1 data.csv && tail -n +2 data.csv | sort -t',' -k2) | column -t -s ','printf '%-15s %s\n' 'Key' 'Value' && printf '%-15s %s\n' <pairs> — Manual column formatting with printf when column is not flexible enough.
printf '%-15s %s\n' 'Host' 'example.com' 'Port' '443' 'Protocol' 'HTTPS'awk -F: '{print $1, $3, $7}' /etc/passwd | column -t — Select specific fields with awk and format as aligned table.
awk -F: '{print $1, $3, $7}' /etc/passwd | column -tcolumn -t -s ',' -o ' | ' <file> — Convert CSV to a pipe-separated table (Markdown-like).
column -t -s ',' -o ' | ' data.csvpaste <file1> <file2> | column -t -s $'\t' — Merge two files side by side and align as table.
paste names.txt scores.txt | column -t -s $'\t' Conclusion
column turns unreadable data streams into clean tables with a single -t – unbeatable for making command output or CSV files scannable in the terminal. Watch out for two pitfalls, though. First, column is not the same everywhere – the powerful options (-N, -O, -H, -J) come from util-linux and are missing on BSD/macOS, where column is much leaner. Second, with -s column does not merge consecutive delimiters by default, so empty fields can show up as separate columns. For pure display column is perfect; for processing data, reach for cut, awk or a proper CSV parser instead.
Further Reading
- column(1) man page (util-linux) – official reference for all options
- util-linux project – the package that provides the modern column implementation