|FMT(1)||General Commands Manual||FMT(1)|
fmt — simple text
fmt is a simple text formatter which reads
the concatenation of input files (or standard input if none are given) and
produces on standard output a version of its input with lines as close to
the goal length as possible without exceeding the
maximum. The goal length
defaults to 65 and the maximum to 10 more than the
Alternatively, a single width parameter can
be specified either by prepending a hyphen to it or by using
-w. For example, “fmt -w 72”,
“fmt -72”, and “fmt 72 72” all produce identical
output. The spacing at the beginning of the input lines is preserved in the
output, as are blank lines and interword spacing. Lines are joined or split
only at white space; that is, words are never joined or hyphenated.
The options are as follows:
.’), question mark (‘
?’), and exclamation mark (‘
!’). Remember that some characters may need to be escaped to protect them from the shell.
.’ (dot) character. Normally,
fmtdoes not fill these lines, for compatibility with troff and nroff.
-pflag, any change in the amount of whitespace at the start of a line results in a new paragraph being begun.
fmt is meant to format mail messages prior
to sending, but may also be useful for other simple tasks. For instance,
within an editor such as vi(1),
the following command will reformat a paragraph, evening the lines:
fmt utility exits 0 on success,
and >0 if an error occurs. The latter happens with invalid
options, insufficient memory, or when an input file is not found or not
readable. The >0 exit value is the sum of all errors up to a maximum of
127; more errors may occur but the counter will only increment to this
fmt command first appeared in
The version described herein is a complete rewrite and appeared in OpenBSD 2.4.
Kurt Shoens (July 1978)
Liz Allen (added goal length concept)
Gareth McCaughan (wrote this version)
The program was designed to be simple and fast – for more complex operations, the standard text processors are likely to be more appropriate.
When the first line of an indented paragraph is very long (more than about twice the goal length), the indentation in the output can be wrong.
fmt is not infallible in guessing what
lines are mail headers and what lines are not.
|October 24, 2016||OpenBSD-6.1|