2 Invoking tabfmt
tabfmt
reads lines from one or more files, breaks the lines into
fields given a set of input field delimiters, and prints a table with
constant-width columns to standard output. Standard input is used for a
file name of `-' or if no input files are given.
The format for running the tabfmt
program is:
tabfmt option... file...
In the table which follows, the width-list, padding-list and
alignment-list are comma-separated lists. Each list element refers
to the corresponding field in the input. If the number of fields exceeds
the number of list elements, the last element counts for all remaining
fields.
The program accepts the following options:
- `-d string'
- `--delimiter=string'
- Break the input lines into fields at any of the characters in
string. By default, input fields are delimited by the characters
in the IFS environment variable. If this environment variable is
not set, `TAB' and `SPC' will be used as the default.
The following backslash-escaped characters are recognized:
- `\a'
- alert (`BEL')
- `\b'
- backspace (`BS')
- `\f'
- form feed (`FF')
- `\n'
- new line (`LF')
- `\r'
- carriage return (`CR')
- `\t'
- horizontal tab (`TAB')
- `\v'
- vertical tab (`VT')
- `\\'
- backslash (`\')
- `\nnn'
- the character whose ASCII code is nnn (octal); if
nnn is not a valid octal number, its value is taken literally.
The input delimiter does not appear in the output (see the description
of --output-delimiter instead). If a sequence of input
delimiters appears in the input, each pair of delimiters is taken to
enclose an empty field.
- `-w width-list'
- `--widths=width-list'
- Determine the minimum and maximum output width of each field. By
default, the width of a field is determined by its widest entry in all
lines.
Each element of width-list has one of the following forms:
- `'
- An empty element poses no constraints on the width of a field. The width
is determined by the widest entry occurring at this field in all lines.
- `n-'
- Use at least n characters for this field. If an entry has less
characters, the missing characters are filled with spaces, or the
character specified with the option --filler.
- `-n'
- Use at most n characters for this field. If an entry has more
characters, the remaining characters are cut off.
- `n-m'
- Use at least n and at most m characters for this field.
- `n'
- Use exactly n characters for this field.
- `-e'
- `--equal-width'
- Use the same width for all fields. The width is determined by the widest
entry in all fields. If a minimum or maximum width is specified (see
the description of --widths), all but the first element of
width-list are ignored.
- `-f character'
- `--filler=character'
- If an entry has less characters than the field width, fill the missing
characters with character; default is `SPC'. The same
backslash-escaped characters are recognized as for the option
--delimiter.
- `-a alignment-list'
- `--align=alignment-list'
- Determine the alignment of each field. By default, all fields are
left-aligned. Elements of alignment-list have the following form:
- `l' or `L'
- Align the entry to the left of the field.
- `r' or `R'
- Align the entry to the right of the field.
- `c' or `C'
- Center the entry in the field.
- `-p padding-list'
- `--padding=padding-list'
- Determine the number of padding characters of each field. By default,
fields have no padding. The padding will appear both at the left and the
right of the field. Note that the padding does not contribute to the
field width.
- `-l padding-list'
- `--left-padding=padding-list'
- Determine the left padding of each field (see the description of
--padding).
- `-r padding-list'
- `--right-padding=padding-list'
- Determine the right padding of each field (see the description of
--padding).
- `-P character'
- `--padder=character'
- If a padding is specified for any field, fill it with character;
default is `SPC' (see the description of --padding). The
same backslash-escaped characters are recognized as for the option
--delimiter.
- `-D string'
- `--output-delimiter=string'
- Separate the fields by string in the output; default is
`TAB'. The same backslash-escaped characters are recognized as for
the option --delimiter.
- `-o file'
- `--output=file'
- Write the output to the file file. By default, the table is
written to standard output.
- `--debug'
- Produce debugging information.
- `-h'
- `--help'
- Print an informative help message describing the options and then exit.
- `-V'
- `--version'
- Print the version number of
tabfmt
and then exit.
An exit status of zero indicates success, and a nonzero value indicates
failure.
Note that each line in the input can have a different number of fields;
in this case, the lines will also have different numbers of fields in
the output. In other words, no fields are added in the output.
If multiple files are specified, they will be treated as a single
dataset. In particular, the field widths are not computed per input
file; they are computed over the entire input.