Linux and Unix fmt command

Quick links

About fmt
Syntax
Examples
Related commands
Linux and Unix main page

About fmt

Simple text formatters.

Syntax

fmt [-c] [-s] [-w width | -width ] [inputfile]

-cCrown 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.
-sSplit 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 | -widthFill output lines to up to width columns.
inputfileThe input file.

Examples

fmt myfile.txt

Display a formatted version of the file myfile.txt. To direct the results to another file (such as myfile2.txt) type the below command.

fmt < myfile.txt > myfile2.txt

Related commands

nroff
vi