fold(C)
fold --
filter for folding lines
Syntax
fold [ -bs ] [ -w width]
[file ... ]
Description
fold breaks lines by inserting a newline character, so
that no output line exceeds a maximum width. fold reads
the named files (or the standard output if no files are named) and
writes to the standard output. It is usually used to send files to
printers that truncate long lines.
If a carriage return, backspace or tab character is found in the
input (and the -b option is not specified) then it is
treated as follows:
backspace-
The current line position is decremented by one. A newline character
is not inserted immediately before or after a backspace character.
carriage return-
The current line position is reset to zero. A newline character is
not inserted immediately before or after a carriage return.
tab -
The current line position is advanced to the next tab stop. Tab
stops are set every eighth column.
The following options are recognized by fold:
-b-
Turn off the special treatment of backspace, carriage return and tab
characters (as described above).
-s-
If a line contains blank characters within the first width
positions, break the line after the last such blank character. (If
there is no such blank character, the -s has no effect.)
This option is useful for readable text files; it ensures that lines
are broken on word boundaries rather than in the middle of a word.
-w width-
width is the column width in column positions. The default
value is 80.
Exit values
An exit value of 0 indicates that the files were processed
successfully. An exit value greater than 0 indicates that an error
occurred.
Examples
fold -s -w72 <myfile.txt >myfile.txt.2
Filters myfile.txt to myfile.txt.2, breaking
lines at the last blank character encountered within a width of 72
columns.
Limitations
Input files must be text files with lines limited to
{LINE_MAX} bytes in length, unless the -b option
is given.
See also
cut(C),
expand(C)
Standards conformance
fold is conformant with:
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005