Simple text formatter. Reformat paragraph text, fill and join lines to produce output lines of a given width (75 characters by default).
Syntax fmt [-cmnps] [-d chars] [-l num] [-t num] [goal [maximum] | -width | -w width] [file ...] Options -c Center the text, line by line. In this case, most of the other options are ignored; no splitting or joining of lines is done. -d chars Treat the chars (and no others) as sentence-ending characters. By default the sentence-ending characters are full stop (`.'), question mark (`?') and exclamation mark (`!'). Remember that some characters need to be escaped to protect them from your shell. -l number Replace multiple spaces with tabs at the start of each output line, if possible. Each number spaces will be replaced with one tab. The default is 8. If number is 0, spaces are preserved. -m Try to format mail header lines contained in the input sensibly. -n Format lines beginning with a `.' (dot) character. Normally, fmt does not fill these lines, for compatibility with nroff(1). -p Allow indented paragraphs. Without the -p flag, any change in the amount of whitespace at the start of a line results in a new paragraph being begun. -s Collapse whitespace inside lines, so that multiple whitespace characters are turned into a single space. (Or, at the end of a sentence, a double space.) -t number Assume that the input files' tabs assume number spaces per tab stop. The default is 8. -w width Fill output lines up to WIDTH characters (default 75).
The fmt utility is a simple text formatter which reads the concatenation of input files (or standard input if none are given) and produces on standard output a version of its input with lines as close to the goal length as possible without exceeding the maximum.
The fmt utility is meant to format mail messages prior to sending, but can also be useful for other simple tasks.
The goal length defaults to 65 and the maximum length to 10 more than the goal length.
Alternatively, a single width parameter can be specified either by prepending a hyphen to it or by using -w.
For example, `fmt -w 72', `fmt -72', and `fmt 72 72' all produce identical output.
The spacing at the beginning of the input lines is preserved in the output, as are blank lines and interword spacing. Lines are joined or split only at white space; that is, words are never joined or hyphenated.
"Everything flows and nothing abides; everything gives way and nothing stays fixed" ~ Heraclitus
Related macOS commands:
cut - Divide a file into several parts.
fold - Wrap input lines to fit in specified width.
join - Join lines on a common field.
paste - Merge lines of files.
split - Split a file into fixed-size pieces.
tr - Translate, squeeze, and/or delete characters.
tail - Output the last part of files.