Manual / fold
fold(1)
| FOLD(1) | General Commands Manual | FOLD(1) |
NAME
fold - break long lines
SYNOPSIS
fold [ -bs ] [ -w width ] [ file ] ...
DESCRIPTION
Fold breaks each line of each named file (standard input default) so that no output line exceeds width columns (80 by default), writing a newline at each break.
In the default mode a tab advances to the next multiple-of-8 column and a backspace moves back one column (never past 0); a tab that would push the column past width forces a break before the tab rather than after it, unless the line is already empty, in which case the overshoot is accepted rather than looping forever. -b counts width in raw bytes instead, with no tab or backspace handling at all.
-w width sets the width explicitly.
-s breaks after the last <blank> (<space> or <tab>) within the width instead of exactly at the width, provided the line has one; a line with no blank in range breaks at the width regardless.
Multiple files are folded independently: the column state starts fresh at each operand, and an unterminated final line is flushed as it stands, without a synthesized newline — so two files, the first ending without one, may appear to run together on one output line.
FILES
/usr/man/FOLD this page
SEE ALSO
DIAGNOSTICS
Exit status is 0; 1 if a file named on the command line could not be opened — that file is skipped, a diagnostic naming it is written to standard error, and the remaining operands are still processed; 2 for a usage error, including -w 0 or a width over 120.
BUGS
The width is capped at 120 columns.
| September 14, 2026 | maux |