The fmt
command is used to format text files. It reads the content from a specified file, reorganizes it according to the specified format, and outputs it to the standard output device. If the specified file name is -
, the fmt
command will read data from the standard input device.
-c, --crown-margin
: Retains indentation of the first two lines.-p, --prefix=STRING
: Only reformats the lines starting with STRING
and reattaches the prefix to the reformatted lines.-s, --split-only
: Splits long lines without reflowing them.-t, --tagged-paragraph
: Indents the first line differently from the second line.-u, --uniform-spacing
: One space between words, two spaces after sentences.-w, --width=WIDTH
: Maximum line width (default to 75
columns).-g, --goal=WIDTH
: Target width (default to 93%
of width).--help
: Output help information.--version
: Output version information.By default, fmt
formats all the words in the given file into a single line, with a default maximum width of 75
.
Format the file and use the -w
option to specify the maximum line width, breaking the words to a new line if they exceed the specified length.
The -s
option splits long lines but does not reflow them.