commands

fmt — reflow text paragraphs

Reformat plain-text paragraphs toward a target width; -w sets maximum width (except indivisible long words). Can alter record boundaries; avoid for structured data. Example assumes a fresh text-streams lab fixture.

Formal Syntax & Structure

linux syntaxlinux
fmt [OPTION]... [FILE]...

Parameters & Attributes

NameTypeDescription
-woptionTakes a maximum line width in columns; an indivisible long word can exceed it.
FILEoperandInput file; omit or use - to read stdin.

Return Value

exit status and output

GNU fmt writes reformatted text and returns nonzero on read/write errors. Long indivisible words may exceed the requested width without failure; compare output before using it as a record format.

Working Example

Example Snippetlinux
fmt -w 20 paragraph.txt
Linux Reference