commands

fold — wrap long lines

Wrap input lines to selected width (default 80 columns), -s prefers blanks, -b counts bytes rather than columns. Produces altered line boundaries on stdout. Example assumes a fresh text-streams lab fixture.

Formal Syntax & Structure

linux syntaxlinux
fold [OPTION]... [FILE]...

Parameters & Attributes

NameTypeDescription
-woptionWidth
-soptionBreak at blanks
-boptionCount bytes
FILEoperandInput file

Return Value

exit status and output

GNU fold writes wrapped text and returns nonzero on read/write errors. Short input can pass through unchanged; verify line width according to the chosen column/byte mode.

Working Example

Example Snippetlinux
fold -w 4 long.txt
Linux Reference