table manual


TABLE(1)                    General Commands Manual                   TABLE(1)




NAME

       table - Command line utility to format and display CSV.


COMMAND ALIASES

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


SYNOPSIS

       table [-h | --help]

       table [-v | --version]

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


COPYRIGHT

       table Copyright © 2020-2023 Strahinya Radich.
       This  program  is  licensed under GNU GPL v3 or later. See the file LI-
       CENSE in the table repository for details.


DESCRIPTION

       table is a command line utility to format and display CSV.   It  parses
       the  given  file  or standard input as CSV and prints out a table 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.


OPTIONS

       -a 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.

       -b
       --border-mode
              Border mode: force single column.

       -c cols
       --columns=cols
              Set maximum table width in columns (default 80).

       -D
       --align-dot
              Set alignment character to dot "." instead of a space " ".

       -d delim
       --delimiter=delim
              Set field delimiter (default ",").  First line of the input  de-
              termines  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 charac-
              ters" for the assignment.

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

       -f 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  |
                   +----+------------------+------------------+----+


       -H
       --align-header
              Makes  the  column  alignment also apply to header row.  The de-
              fault behavior is to print header cells left-aligned.

       -h
       --help
              Print the usage information screen.

       -m
       --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.

       -n
       --no-ansi
              Turn off ANSI SGR codes in the output.  By default,  the  header
              row  is  printed in bold using ANSI codes.  This switch prevents
              that.

       -p
       --pause
              Presents the message "Press Enter to continue" and waits for in-
              put  after outputting the table. This accounts for executing ta-
              ble from file managers which don't pause  after  executing  pro-
              grams or as a single command from terminal emulators.

       -q behavior
       --quotes=behavior
              behavior can be one of the following:

              process
                     Treats  everything between the quotes as a single column.
                     Treats consecutive quotes within the quoted text as  lit-
                     eral quotes.  This is the default.

              ignore Ignores  the  special meaning of quotes (like TSV).  This
                     is the default if table is called as tsvtable.

       -s set
       --symbols=set
              Use table symbol set set for table lines, where set  is  one  of
              the following (format: <border><inner border>):

              +------------------------------+
              |aa   ascii-ascii,             |
              +------------------------------+
              |ss   single-single,           |
              +------------------------------+
              |sd   single-double,           |
              +------------------------------+
              |ds   double-single (default), |
              +------------------------------+
              |dd   double-double,           |
              +------------------------------+
              |ee   empty-empty,             |
              +------------------------------+
              |ae   ascii-empty,             |
              +------------------------------+
              |se   single-empty,            |
              +------------------------------+
              |de   double-empty,            |
              +------------------------------+
              |ea   empty-ascii,             |
              +------------------------------+
              |es   empty-single,            |
              +------------------------------+
              |ed   empty-double.            |
              +------------------------------+
       -t
       --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  ig-
              nored.

       -v
       --version
              Print program version and exit.


SEE ALSO

       awk(1), sed(1)


EXAMPLES

       Periodically display CPU load information in a single-line table

           $ watch "table /proc/loadavg -d ' ' -c 50 -n -s ss"


       Format  a  long list of files in the current directory in a double line
       table with single-line column divisors

           $ LC_ALL=C ls -l | tail -n +2 | sed -e 's/ \+/ /g' | table -d ' ' -n


       Print information from /etc/passwd in a table:

           $ table -n -d : -f 3:1:1:1:4:4:4 /etc/passwd


       Same as above, without borders and with different column alignment:

           $ table -n -H -d: -arccclll -see -f3:1:1:1:4:4:4 /etc/passwd



AUTHOR

       Strahinya Radich, <https://strahinja.org>


BUGS

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



0.6.22                         October 05, 2023                       TABLE(1)