fold is a filter that folds lines from its input, breaking the lines to have a maximum of
width column positions (or
bytes if the
-b option is specified). Lines are broken by the insertion of a newline character such that each output line is
the maximum width possible that does not exceed the specified number of column positions, (or bytes). A line will not be broken in
the middle of a character.
Unless the -b option is specified, the following will be treated specially:
- carriage-return
The current count of line width will be set to zero. fold will
not insert a newline immediately before or after a carriage-return.
- backspace
If positive, the current count of line width will be decremented by one. fold
will not insert a newline immediately before or after a backspace.
- tab
- Each tab character encountered will advance the column position to the next tab stop. Tab stops are
at each column position n, where n modulo 8 equals 1.
If no
file is given, or if the
file is
-,
fold reads from standard input. The start of the file is
defined as the current offset.