fmt(1) User Commands fmt(1)NAME
fmt - simple text formatters
SYNOPSIS
fmt [-cs] [-w width | -width] [inputfile...]
DESCRIPTION
fmt is a simple text formatter that fills and joins lines to produce output lines of (up to) the number of characters specified in the -w
width option. The default width is 72. fmt concatenates the inputfiles 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. fmt does not fill nor split lines beginning with a `.' (dot), for
compatibility with
nroff(1). Nor does it fill or split a set of contiguous non-blank lines which is determined to be a mail header, the first line of which
must begin with "From".
Indentation is preserved in the output, and input lines with differing indentation are not joined (unless -c is used).
fmt can also be used as an in-line text filter for vi(1). The vi command:
!}fmt
reformats the text between the cursor location and the end of the paragraph.
OPTIONS -c 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. This is useful for tagged paragraphs.
-s 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 combined.
-w width | -width Fill output lines to up to width columns.
OPERANDS
inputfile Input file.
ENVIRONMENT VARIABLES
See environ(5) for a description of the LC_CTYPE environment variable that affects the execution of fmt.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO nroff(1), vi(1), attributes(5), environ(5)NOTES
The -width option is acceptable for BSD compatibility, but it may go away in future releases.
SunOS 5.10 9 May 1997 fmt(1)
Check Out this Related Man Page
FMT(1) BSD General Commands Manual FMT(1)NAME
fmt -- simple text formatter
SYNOPSIS
fmt [-cmnps] [-d chars] [-l num] [-t num] [goal [maximum] | -width | -w width] [file ...]
DESCRIPTION
The fmt utility 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 goal length. Alternatively, a single width parameter can be specified either by prepend-
ing 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:
-c Center the text, line by line. In this case, most of the other options are ignored; no splitting or joining of lines is done.
-m Try to format mail header lines contained in the input sensibly.
-n Format lines beginning with a '.' (dot) character. Normally, fmt does not fill these lines, for compatibility with nroff(1).
-p Allow indented paragraphs. Without the -p flag, any change in the amount of whitespace at the start of a line results in a new para-
graph being begun.
-s Collapse whitespace inside lines, so that multiple whitespace characters are turned into a single space. (Or, at the end of a sen-
tence, a double space.)
-d chars
Treat the chars (and no others) as sentence-ending characters. By default the sentence-ending characters are full stop ('.'), ques-
tion mark ('?') and exclamation mark ('!'). Remember that some characters may need to be escaped to protect them from your shell.
-l number
Replace multiple spaces with tabs at the start of each output line, if possible. Each number spaces will be replaced with one tab.
The default is 8. If number is 0, spaces are preserved.
-t number
Assume that the input files' tabs assume number spaces per tab stop. The default is 8.
The fmt utility is meant to format mail messages prior to sending, but may also be useful for other simple tasks. For instance, within vis-
ual mode of the ex(1) editor (e.g., vi(1)) the command
!}fmt
will reformat a paragraph, evening the lines.
ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of fmt as described in environ(7).
SEE ALSO fold(1), mail(1), nroff(1)HISTORY
The fmt command appeared in 3BSD.
The version described herein is a complete rewrite and appeared in FreeBSD 4.4.
AUTHORS
Kurt Shoens
Liz Allen (added goal length concept)
Gareth McCaughan
BUGS
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.
The fmt utility is not infallible in guessing what lines are mail headers and what lines are not.
BSD August 2, 2004 BSD