Fmt (Unix)


The command in Unix and Unix-like operating systems is used to format natural language text for humans to read.

Overview

The command has been traditionally used to reformat email messages after composition and prior to delivery. Its syntax is similar among various Unixes, but not identical. attempts to break, fill and join input lines to produce globally optimal, balanced output with the lengths of each line approaching the target width as closely as possible, rather than wrapping the input lines exactly as fold | does.
In most implementations of, the word wrap optimization procedure usually requires two criteria: the target output line width, and the maximum acceptable line width. It might be not always possible to give these two options simultaneously. For example, early versions of GNU can only accept the maximum width option, which is given by switch, or directly as the first command line option for compatibility. See the Solaris man page for and FreeBSD manual entry for for detailed examples, and compare with the latest documentation of GNU utility included by most Linux distributions. See also the Plan 9 man page.
Unlike Par |, has no Unicode support, and does not support text justification.

Example

Given text like this as input:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dignissim
venenatis pede. Quisque dui dui, ultricies ut, facilisis non, pulvinar non. Duis quis arcu a purus volutpat iaculis. Morbi id dui in diam ornare
dictum. Praesent consectetuer vehicula ipsum. Praesent tortor massa, congue et,
ornare in, posuere eget, pede.
Vivamus rhoncus. Quisque lacus. In hac habitasse platea dictumst. Nullam mauris
tellus, sollicitudin non, semper eget, sodales non, pede. Phasellus varius
ullamcorper libero. Fusce ipsum lorem, iaculis nec, vulputate vitae, suscipit
vel, tortor. Cras varius.
Nullam fringilla pellentesque orci. Nulla eu ante pulvinar velit rhoncus
lacinia. Morbi fringilla lacus quis arcu. Vestibulum sem quam, dapibus in,
fringilla ut, venenatis ut, neque.

After passing this through, the width of each line is at most 50 characters and the text flows within this constraint:

Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur dignissim venenatis
pede. Quisque dui dui, ultricies ut, facilisis
non, pulvinar non, purus. Duis quis arcu a
purus volutpat iaculis. Morbi id dui in diam
ornare dictum. Praesent consectetuer vehicula
ipsum. Praesent tortor massa, congue et, ornare
in, posuere eget, pede.
Vivamus rhoncus. Quisque lacus. In hac
habitasse platea dictumst. Nullam mauris tellus,
sollicitudin non, semper eget, sodales non,
pede. Phasellus varius ullamcorper libero. Fusce
ipsum lorem, iaculis nec, vulputate vitae,
suscipit vel, tortor. Cras varius.
Nullam fringilla pellentesque orci. Nulla eu ante
pulvinar velit rhoncus lacinia. Morbi fringilla
lacus quis arcu. Vestibulum sem quam, dapibus in,
fringilla ut, venenatis ut, neque.