opscape

Text processing

column

Format input into aligned columns or a table; turns CSV and whitespace data into readable output.

column [OPTION...] [FILE...]

10 of 10 examples run in Debian 13.7 on 2026-10-31 · bsdextrautils 2.41.5-0+deb13u1 · manual: column(1)

column has two modes. With -t it builds a table: it splits each line into fields (on whitespace, or on the characters given with -s) and pads every field so the columns line up. Without -t it fills a list of short items into as many columns as fit the screen width, like ls does.

column -t -s, is the fastest way to read a CSV in the terminal. The Linux version (from util-linux, in Debian's bsdextrautils package) adds much more: custom output separators, right-aligned columns, header names, hiding columns and even JSON output. It is not a CSV parser, though: it does not understand quoted fields with commas inside.

Examples

Read a CSV as an aligned table

column -t -s , data/users.csv | head -n 5
explain
output
id  name           email               dept         joined
1   Alice Moreau   alice@example.com   engineering  2021-04-12
2   Bob Okafor     bob@example.com     sales        2019-11-03
3   Chen Wei       chen@example.com    engineering  2023-01-20
4   Dana Kowalski  dana@example.com    support      2022-07-08

-t makes a table and -s , splits fields on commas. Each column is padded to its widest value, so the names and emails line up.

Align whitespace-separated data

column -t data/hosts.txt
explain
output
web01    10.0.0.11
web02    10.0.0.12
db01     10.0.0.21
cache01  10.0.0.31

Without -s, fields are split on runs of spaces and tabs, so ragged two-column data gets a straight second column.

Tidy up a command's output

printf '%s %s %s\n' NAME SIZE TYPE app.py 17 python helpers.py 3 python main.c 6 c | column -t
explain
output
NAME        SIZE  TYPE
app.py      17    python
helpers.py  3     python
main.c      6     c

Any command that prints space-separated fields can be piped through column -t for a neat table.

Draw visible column separators

column -t -s , -o ' | ' data/sales.csv | head -n 4
explain
output
date       | region | product | units | price
2026-03-01 | north  | widget  | 12    | 4.50
2026-03-01 | south  | gadget  | 3     | 19.99
2026-03-02 | east   | widget  | 7     | 4.50

-o ' | ' sets what goes between output columns (two spaces by default), giving a Markdown-like table.

Right-align numeric columns

column -t -s $'\t' -R 2,3 data/inventory.tsv
explain
output
name    qty  price
widget   12   4.50
gadget    3  19.99
gizmo     5  12.00

-s $'\t' splits on tabs (bash turns $'\t' into a real tab) and -R 2,3 right-aligns the quantity and price columns so the digits line up.

Name and hide columns

tail -n +2 data/users.csv | column -t -s , -N id,name,email,dept,joined -H email,joined | head -n 4
explain
output
id  name           dept
1   Alice Moreau   engineering
2   Bob Okafor     sales
3   Chen Wei       engineering

-N names the columns and prints the names as a header line; -H then hides columns by name. The file's own header is skipped with tail -n +2, otherwise it would appear twice.

Convert a table to JSON

tail -n +2 data/users.csv | head -n 2 | column -J -s , -n users -N id,name,email,dept,joined
explain
output
{
   "users": [
      {
         "id": "1",
         "name": "Alice Moreau",
         "email": "alice@example.com",
         "dept": "engineering",
         "joined": "2021-04-12"
      },{
         "id": "2",
         "name": "Bob Okafor",
         "email": "bob@example.com",
         "dept": "sales",
         "joined": "2019-11-03"
      }
   ]
}

-J writes JSON: an object whose key is the table name from -n, holding one object per row keyed by the column names from -N. All values are strings.

Fill a list into columns

seq 1 12 | column -c 40
explain
output
1	4	7	10
2	5	8	11
3	6	9	12

Without -t, items are arranged in columns down the page, as many as fit into the width given by -c (the terminal width by default). The gaps are tab characters.

Fill rows first

seq 1 12 | column -x -c 40
explain
output
1	2	3	4	5
6	7	8	9	10
11	12

-x fills across each row before starting the next, so the numbers read left to right.

Empty fields are kept

printf 'host,port,user\nweb01,,admin\ndb01,5432,\n' | column -t -s ,
explain
output
host   port  user
web01        admin
db01   5432  

The missing port of web01 and the missing user of db01 stay as blank cells, so the columns don't shift. The BSD/macOS column merges adjacent separators instead.

Common pitfalls

  • column -t -s, is not a CSV parser: a quoted field such as "Smith, Jane" is split at its comma. Use a real CSV tool (python's csv module, mlr, csvlook) for such files.

  • BSD/macOS column treats several adjacent separators as one, so empty CSV fields shift the following values one column left. util-linux column on Linux keeps empty fields.

  • column reads all input before printing anything, because it needs every row to compute widths. It is useless with tail -f and slow on huge files.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • The Linux (util-linux) column options -o, -R, -N, -H, -J, -n, -W and long options are not available in the BSD/macOS version, which has essentially -t, -s, -c and -x.

Options worth knowing

A selection, described in our own words. For the full list, see column(1) or column --help.

OptionWhat it does
-t, --tableBuild a table: split lines into fields and align them.
-s, --separator CHARSCharacters that separate input fields in table mode (whitespace by default).
-o, --output-separator STRINGString placed between output columns (two spaces by default).
-R, --table-right COLUMNSRight-align these columns (numbers or names).
-N, --table-columns NAMESComma-separated names for the columns.
-H, --table-hide COLUMNSDo not print these columns.
-O, --table-order COLUMNSPrint columns in this order.
-J, --jsonOutput JSON; needs column names from -N.
-n, --table-name NAMEName of the table, used as the JSON key.
-W, --table-wrap COLUMNSAllow these columns to wrap their text.
-c, --output-width WIDTHOutput width in characters for fill mode.
-x, --fillrowsFill rows before columns.
-L, --keep-empty-linesKeep empty input lines instead of skipping them.

Related