fold
wrap each input line to fit in specified width

Wrap input lines in each FILE (standard input by default), writing to standard output.

Example:

fold --spaces --width=70

-s
--spaces
break at spaces
-w
--width=width
Default: 80
-c
--characters
count characters rather than columns
-b
--bytes
count bytes rather than columns
--help
--version

[TAB] characters (x'09') are problematic.
For example:

 cat 0
    PID    PPID COMMAND                     PRI     TIME PRI  NI
 369055  369052 -jailshell                   22     00:00:00  22   0
 651669  369055 -jailshell                   21     00:00:00  21   0
In fact the spaces before the 00: are tab characters.

 hexdump -C 0
00000000  20 20 20 20 50 49 44 20  20 20 20 50 50 49 44 20  |    PID    PPID |
00000010  43 4f 4d 4d 41 4e 44 20  20 20 20 20 20 20 20 20  |COMMAND         |
00000020  20 20 20 20 20 20 20 20  20 20 20 20 50 52 49 20  |            PRI |
00000030  20 20 20 20 54 49 4d 45  20 50 52 49 20 20 4e 49  |    TIME PRI  NI|
00000040  0a 20 33 36 39 30 35 35  20 20 33 36 39 30 35 32  |. 369055  369052|
00000050  20 2d 6a 61 69 6c 73 68  65 6c 6c 20 20 20 20 20  | -jailshell     |
00000060  20 20 20 20 20 20 20 20  20 20 20 20 20 20 32 32  |              22|
00000070  20 09 30 30 3a 30 30 3a  30 30 20 20 32 32 20 20  | .00:00:00  22  |
00000080  20 30 0a 20 36 35 31 36  36 39 20 20 33 36 39 30  | 0. 651669  3690|
00000090  35 35 20 2d 6a 61 69 6c  73 68 65 6c 6c 20 20 20  |55 -jailshell   |
000000a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000b0  32 31 20 09 30 30 3a 30  30 3a 30 30 20 20 32 31  |21 .00:00:00  21|
000000c0  20 20 20 30 0a                                    |   0.|
000000c5

See also

expand, fmt

fmt
simple text formatter

fmt [-cmnps] [-d chars] [-l num] [-t num] [goal [maximum] | -width | -w width] [file ...] 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 goal length defaults to 65 and the maximum 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 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.
-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.
-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.
-p Allow indented paragraphs. Otherwise 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.)
-d chars Treat chars (and no others) as sentence-ending characters. Default: full stop (`.'), question mark (`?') and exclamation mark (`!').
Some characters may need to be escaped to protect them from shell expansion.
-l n Replace n spaces with tabs at the start of each output line. Default: 8. If n is 0, spaces are preserved.
-t number input files' tabs assume spaces per tab stop. The default is 8.

Meant to format mail messages prior to sending, fmt is useful for other simple tasks. For instance, within visual mode of the ex(1) editor (e.g., vi(1)) the command

!}fmt
will reformat a paragraph, evening the lines.

ENVIRONMENT

The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of fmt as described in environ

SEE ALSO

fold(1), mail, nroff