Linux fmt command
Updated: 05/04/2019 by Computer Hope
On Unix-like operating systems, the fmt command is a formatter for simplifying and optimizing text files.
This page covers the GNU/Linux version of fmt.
Description
fmt reformats each paragraph in the FILE(s) specified, writing to standard output. The option -WIDTH is an abbreviated form of --width=DIGITS.
Syntax
fmt [-WIDTH] [OPTION]... [FILE]...
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.