OpenBSD manual page server

Manual Page Search Parameters

FOLD(1) General Commands Manual FOLD(1)

foldfold long lines for finite width output device

fold [-bs] [-w width] [file ...]

fold is a filter which folds the contents of the specified files, or the standard input if no files are specified, breaking the lines to have a maximum of 80 display columns.

The options are as follows:

Count width in bytes rather than column positions.
If an output line would be broken after a non-blank character but contains at least one blank character, break the line earlier, after the last blank character. This is useful to avoid line breaks in the middle of words, if possible.
width
Specifies a line width to use instead of the default of 80.

Unless -b is specified, a backspace character decrements the column position by one, a carriage return resets the column position to zero, and a tab advances the column position to the next multiple of eight.

The character encoding locale(1). It decides which byte sequences form characters and what their display width is. If unset or set to "C", "POSIX", or an unsupported value, each byte except backspace, tab, newline, and carriage return is treated as a character of display width 1.

The fold utility exits 0 on success, and >0 if an error occurs.

expand(1), fmt(1)

The fold utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification.

The fold utility first appeared in 1BSD. It was rewritten for 4.3BSD-Reno to improve speed and modernize style. The -b and -s options were added to NetBSD 1.0 for IEEE Std 1003.2 (“POSIX.2”) compliance.

Bill Joy wrote the original version of fold on June 28, 1977. Kevin Ruddy rewrote the command in 1990, and J. T. Conklin added the missing options in 1993.

Traditional roff(7) output semantics, implemented both by GNU nroff and by mandoc(1), only uses a single backspace for backing up the previous character, even for double-width characters. The fold backspace semantics required by POSIX mishandles such backspace-encoded sequences, breaking lines early. The fmt(1) utility provides similar functionality and does not suffer from that problem, but isn't standardized by POSIX.

October 24, 2016 OpenBSD-current