Linux and Unix fmt command

Quick links

About fmt
Syntax
Examples
Related commands
Linux and Unix main page

About fmt

fmt is a formatter for simplifying and optimizing text files.

Syntax

fmt [-WIDTH] [OPTION]... [FILE]...

Description

fmt reformats each paragraph in the FILE(s) specified, writing to standard output. The option -WIDTH is an abbreviated form of --width=DIGITS.

Options

-c, --crown-margin preserve indentation of first two lines.
-p, --prefix=STRING reformat only lines beginning with STRING, reattaching the prefix to reformatted lines.
-s, --split-only split long lines, but do not refill them.
-t, --tagged-paragraph indentation of first line different from second.
-u, --uniform-spacing Use one space between words, two spaces after sentences.
-w, --width=WIDTH maximum line width (default of 75 columns).
-g, --goal=WIDTH goal width (default of 93% of width).
--help display a help message and exit.
--version Display version information and exit.

If no FILE is specified, or if FILE is a dash ("-"), fmt reads from standard input.

Examples

fmt myfile.txt

Display a reformatted version of the file myfile.txt.

fmt < myfile.txt > myfile2.txt

Reformat myfile.txt, and write the output to the file myfile2.txt.

Related commands

nroff — Format documents for terminal display or line-printer.