fmt - simple optimal text formatter
fmt [-cstu] [-width] [-w width] [-p prefix] [--crown-mar-
gin] [--split-only] [--tagged-paragraph] [--uniform-spac-
ing] [--width=width] [--prefix=prefix] [--help] [--ver-
sion] [file ...]
This documentation is no longer being maintained and may
be inaccurate or incomplete. The Texinfo documentation is
now the authoritative source.
This manual page documents the GNU version of fmt. fmt is
a simple text formatter that fills and joins lines to pro-
duce output lines of (up to) the specified width (default
75). However fmt uses a best-fit line breaking algorithm,
by a simple version of "Breaking Paragraphs into Lines",
Donald E. Knuth and Michael F. Plass, Software--Practice
and Experience 11 (1981) 1119-1184.
fmt concatenates the files listed as arguments. If none
are given, fmt formats text from the standard input.
Blank lines are preserved in the output, as is the spacing
between words (unless -u is used). In contrast to BSD
fmt, tabs are expanded on input and re-introduced on out-
Indentation is preserved in the output, and input lines
with differing indentation are not joined (unless -c or -t
is used). Note that although the BSD fmt manual also
states this, the BSD version does in fact join following
lines with less indentation.
fmt prefers breaking lines at the end of a sentence, and
tries to avoid line breaks after the first word of a sen-
tence or before the last word of a sentence. A sentence
break is defined as either the end of a paragraph or a
word ending in [.?!], followed by two spaces or end of
line, ignoring any intervening parentheses or quotes.
Crown margin mode. Preserve the indentation of the
first two lines within a paragraph, and align the
left margin of each subsequent line with that of
the second line.
Tagged paragraph mode: just like crown mode, except
that the indentation of the first line of a para-
graph must be different from the indentation of the
FSF GNU Text Utilities 1
second. Otherwise the first line is treated as a
Split lines only. Do not join short lines to form
longer ones. This prevents sample lines of code,
and other such "formatted" text, from being unduly
Uniform spacing. Reduce spacing between words to
one space, except at the end of a sentence (two
-width, -w width, --width=width
Fill output lines to up to width columns (default
75). fmt prefers to make lines about 7% shorter,
to give it room to balance line lengths.
Only lines beginning with the prefix (possibly pre-
ceded by white space) are re-arranged; the prefix
(with any preceding white space) is stripped for
the formatting and re-attached to each formatted
output line. One use is to format certain kinds of
program comments, while leaving the code unchanged.
--help Print a usage message and exit with a status code
Print version information on standard output then
FSF GNU Text Utilities 2