column Command Cheat Sheet
column formats its input into multiple columns. It is incredibly useful for turning raw, delimited text output (like CSVs or log files) into human-readable tables in the terminal.
Synopsis
column [options] [file...]
Description
The column utility formats its input into multiple columns. Rows are filled before columns. Input is taken from file operands, or, by default, from standard input.
Basic Usage
Auto-Format Text Table
cat data.txt | column -t
Specify Delimiter (-s)
Format a CSV file readable:
column -s "," -t file.csv
Fill Rows First (-x)
By default, column fills columns first (vertical list). Use -x to fill rows first (horizontal list).
ls -1 | column -x
Table Formatting Options (Modern Versions)
Newer versions of column (util-linux) support advanced table formatting.
Custom Output Separator (-o)
Change the separator between columns in the output (default is two spaces).
mount | column -t -o " | "
Hide Headers
If input has headers you want to clean up manually or re-process.
column --table-noheadings -t data.txt
JSON Output (-J)
Export table data as JSON. Requires specifying column names.
column -t -J --table-columns id,name,age data.txt
Define Column Names (-N)
If input lacks headers, you can provide them.
ps | column -t -N PID,TTY,TIME,CMD
Practical Examples
Format /etc/passwd
Make the password file readable by splitting on :.
column -s ":" -t /etc/passwd | head -n 5
Pretty Print Mount Points
mount | column -t
Align dmesg Output
dmesg | tail | column -t
Display CSV File as Table
# cat users.csv
# id,name,email
# 1,alice,alice@example.com
# 2,bob,bob@example.com
column -s, -t < users.csv
Output:
id name email
1 alice alice@example.com
2 bob bob@example.com
Monitor Disk Usage
Automate df -h alignment (though df usually aligns itself well, this ensures custom parsers work).
df -h | column -t
Advanced Usage
Right Align Specific Columns (-R)
Right-align the 2nd and 3rd columns (useful for numbers).
column -t -R 2,3 data.txt
Truncate Long Text (-T)
Truncate text in specific columns if it exceeds width.
column -t -T 4 very_long_log.txt
Tree-Like Output
If data represents a hierarchy (requires parent-child ID columns):
column --tree-id 1 --tree-parent 2 --tree 3 data.txt
Colors
Colorize output (if supported by terminal and column version).
column --table-columns USER,PID,%CPU,%MEM,COMMAND --color=always
Handling Pipeline Output
Often used with awk, sed, or grep to clean data before formatting.
grep "Error" /var/log/syslog | awk '{print $1,$2,$3,$5}' | column -t
Notes
- Debian/Ubuntu:
columnis part ofbsdmainutilsorutil-linux. - macOS (BSD): Older version of
columncomes pre-installed. It supports-tand-sbut lacks JSON (-J) or advanced table options (--table-*). - Whitespace: Default separator includes tabs and spaces. Use
-s $'\t'for tab-only.
Compatibility Warning
The advanced flags (--table-*, -J, -N) are available in util-linux version (standard on most Linux distros like Ubuntu, Fedora, CentOS).
BSD variants (macOS) generally only support basic -t, -s, and -x.
Check version:
column --version
Exit Status
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error |