TABLE(1) General Commands Manual TABLE(1)

tableCommand line utility to format and display CSV and TSV

table -h | --help | -V | --full-version | -v | --version

table [-a alignment | --align=alignment] [-b | --border-mode] [-c cols | --columns=cols] [-D | --align-dot] [-d delim | --delimiter=delim] [-f format | --format=format] [-H | --align-header] [-m | --msdos] [-n | --no-ansi] [-p | --pause] [-q behavior | --quotes=behavior] [-s set | --symbols=set] [-t | --expand-tabs] [-y | --yes-ansi] [pathname]

tablep is a synonym for ‘table -p’.
tsvtable is a synonym for ‘table -d "$(printf '\t')" -q ignore’.

table is a command line utility to format and display CSV and TSV. It parses the file given by pathname or standard input and prints out a table representing its contents using Unicode characters for box drawing.

When specifying multiple pathname arguments, table prints a warning to stderr. Only the first such argument is processed. If pathname is omitted, table reads standard input.

alignment, --align=alignment
Set column alignments. alignment is a string consisting of characters l, c or r, which respectively set the alignment of the corresponding column to left, center or right. For example, -arccc sets the alignment for the first column to right, and the next three columns to center.
, --border-mode
Border mode: force single column.
cols, --columns=cols
Set maximum table width in columns (default 80).
, --align-dot
Set alignment character to dot “.” instead of a space “ ”.
delim, --delimiter=delim
Set field delimiter (default “,”). First line of the input determines the number of table columns. The first character of delim becomes the delimiter. Special characters, like “;”,need to be quoted or escaped:
$ table -d';'
or
$ table -d\;
In the examples above, “'” and “\” are parsed by the shell and are not passed to table, so are not considered as “first characters” for the assignment.

Note that the -b parameter takes precedence: if it is present, -d is ignored.

format, --format=format
Set widths for individual columns as ratio. Parameter format should be a string of weights separated by colons. For example:
$ table -c 50 -s aa examples/quotes-english.csv
+-----------+-----------+-----------+-----------+
|ID         |Name       |Surname    |Age        |
|001        |John       |Smith      |34         |
|002        |Steven     |Watson     |23         |
|003        |Richard    |Smith      |33         |
|007        |Bond, James|Bond       |46         |
+-----------+-----------+-----------+-----------+
$ table -f 1:2:3:4 -c 50 -s aa examples/quotes-english.csv
+----+---------+-------------+------------------+
|ID  |Name     |Surname      |Age               |
|001 |John     |Smith        |34                |
|002 |Steven   |Watson       |23                |
|003 |Richard  |Smith        |33                |
|007 |Bond, Jam|Bond         |46                |
+----+---------+-------------+------------------+
$ table -f 1:5:5:1 -c 50 -s aa examples/quotes-english.csv
+----+------------------+------------------+----+
|ID  |Name              |Surname           |Age |
|001 |John              |Smith             |34  |
|002 |Steven            |Watson            |23  |
|003 |Richard           |Smith             |33  |
|007 |Bond, James       |Bond              |46  |
+----+------------------+------------------+----+
, --align-header
Makes the column alignment also apply to header row. The default behavior is to print header cells left-aligned.
, --help
Print the usage information screen.
, --msdos
Ignore carriage return (\r) characters in input. The default behavior is to treat them as part of the text, which can produce unexpected results.
, --no-ansi
Turn off ANSI SGR codes in the output. By default, the header row is printed in bold using ANSI codes if the stdout is a tty. This switch prevents that.
, --pause
Presents the message “Press Enter to continue” and waits for input after outputting the table. This accounts for executing table from file managers which don't pause after executing programs or as a single command from terminal emulators.
behavior, --quotes=behavior
behavior can be one of the following:
Treats everything between the quotes as a single column. Treats consecutive quotes within the quoted text as literal quotes. This is the default.
Ignores the special meaning of quotes (like TSV). This is the default if table is called as tsvtable.
set, --symbols=set
Use table symbol set set for table lines, where set is one of the following (format: ⟨border⟩⟨inner border⟩):
ascii-ascii,
ascii-empty,
double-double,
double-single (default),
double-empty,
empty-ascii,
empty-double,
empty-empty,
empty-single,
single-double,
single-empty,
single-single.

Any other value for set will produce an error.

, --expand-tabs
Expand tabs to spaces, honoring standard modulo 8 tab stops. Default behavior is to output tab characters as-is.

Note that the -d parameter takes precedence, unless -b is also used: if the delimiter is set to the TAB character (0x09), -t is ignored. When -b is used in addition, -t is honored and -d ignored.

, --full-version
Print full version (like -v), followed by copyright notice, and exit.
, --version
Print program version and commit date, and exit.
, --yes-ansi
Explicitly turn on ANSI SGR codes in the output. By default, the header row is printed in bold using ANSI codes, unless the stdout is not a tty. This switch enforces the output of ANSI SGR codes, even in that case.

The table utility exits 0 on success, and >0 if an error occurs.

awk(1), sed(1)

Strahinya Radich <sr@strahinja.org>, 2020-2024

Bugs can be reported using the ticket tracker at: https://todo.sr.ht/~strahinja/table

July 15, 2024 OpenBSD 7.5