FOLD(1) | User Commands | FOLD(1) |
fold - filter for folding lines
fold [-bs] [-w width | -width] [file]...
The fold utility is a filter that will fold lines from its input files, breaking the lines to have a maximum of width column positions (or bytes, if the -b option is specified). Lines will be broken by the insertion of a NEWLINE character such that each output line (referred to later in this section as a segment) 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. The behavior is undefined if width is less than the number of columns any single character in the input would occupy.
If the CARRIAGE-RETURN, BACKSPACE, or TAB characters are encountered in the input, and the -b option is not specified, they will be treated specially:
BACKSPACE
CARRIAGE-RETURN
TAB
The following options are supported:
-b
-s
-w width|-width
The following operand is supported:
file
Example 1 Submitting a file of possibly long lines to the line printer
An example invocation that submits a file of possibly long lines to the line printer (under the assumption that the user knows the line width of the printer to be assigned by lp(1)):
example% fold -w 132 bigfile | lp
See environ(7) for descriptions of the following environment variables that affect the execution of fold: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned:
0
>0
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
CSI | enabled |
Interface Stability | Standard |
fold and cut(1) can be used to create text files out of files with arbitrary line lengths. fold should be used when the contents of long lines need to be kept contiguous. cut should be used when the number of lines (or records) needs to remain constant.
fold is frequently used to send text files to line printers that truncate, rather than fold, lines wider than the printer is able to print (usually 80 or 132 column positions).
fold may not work correctly if underlining is present.
February 1, 1995 | OmniOS |