fmt

simple text formatter 

Command


SYNOPSIS

fmt [-bCcjns] [-l n] [-p n] [-w n] [file ...]


DESCRIPTION

fmt is a simple text formatter intended for modest tasks such as formatting mail messages and use within the Vi family of text editors. Formatted output is written to the standard output. fmt reads input from the file arguments on the command line; when there are none of these, it reads from the standard input.

In the output, white space at the beginning of a line consists of tab characters and blanks. White space in the middle of a line is always spaces (which means that fmt converts tabs to spaces).

Normally, fmt ignores line breaks in input, filling output lines. For example,

Mary had a little lamb
Its fleece was white as snow

becomes

Mary had a little lamb Its fleece was white as snow

However, blank lines, changes in indent and input lines starting with a dot (.) do cause a break. In this way, nroff/troff files are preserved.

Options

-b 

assumes block paragraphs (that is, paragraphs are uniformly indented, including first line) and breaks lines on every change of input indentation.

-C 

centers the input lines. fmt ignores the indentation of input lines.

-c 

assumes crown paragraphs (that is, paragraphs start with a line with a negative indent (every line but the first is indented)) and therefore breaks on a decrease in indentation only.

-j 

produces a justified right margin by inserting extra blanks into output lines as necessary.

-l n 

sets the maximum line length to n characters. By default, fmt produces output lines of at most 72 characters. If n equals 0, there is no maximum line length, so paragraphs are output as a single long line. This format is useful as input to word processors which use soft returns within paragraphs and hard returns to terminate paragraphs..

-n 

ignores indent and inter-word space of input lines and squeezes multiple spaces into one. Normally, fmt preserves indentation and inter-word spacing of input lines on output.

-p n 

sets the output page offset to n characters (default 0). fmt adds this offset to the prevailing line indent.

-s 

does not join short lines to form longer lines. This prevents sample lines of code and other such formatted text from being combined unduly.

-w n 

is identical to the -l n option. A value of 0 of n has the same meaning: there is no limit to the maximum line length.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following

— unknown command line option
— missing line length in -l or -w
— invalid line length
— cannot open input file


PORTABILITY

4.2 BSD UNIX and up. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.


LIMITS

A single input line can be up to a maximum of 1000 characters long.


NOTES

Does not center and justify simultaneously -- centering takes priority.

Does not hyphenate.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
mailx, vi


PTC MKS Toolkit 10.4 Documentation Build 39.