User Commands fold(1) NAME fold - filter for folding lines SYNOPSIS /usr/bin/fold /usr/bin/fold [ options ] [file...] ksh93 fold [ options ] [file...] DESCRIPTION fold is a filter that folds lines from its input, breaking the lines to have a maximum of width column positions (or bytes if the -b option is specified). Lines are broken by the insertion of a newline character such that each output line 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. Unless the -b option is specified, the following will be treated specially: carriage-return The current count of line width will be set to zero. fold will not insert a newline immediately before or after a carriage-return. backspace If positive, the current count of line width will be decremented by one. fold will not insert a newline immediately before or after a backspace. tab Each tab character encountered will advance the column position to the next tab stop. Tab stops are at each column position n, where n modulo 8 equals 1. If no file is given, or if the file is -, fold reads from standard input. The start of the file is defined as the current offset. OPTIONS The following options are supported: -b, --bytes Count bytes rather than columns so that each carriage-return, backspace, and tab counts as 1. -c, --continue=text Emit text at line splits. The default value is '\n'. -d, --delimiter=delim Break at delim boundaries. -s, --spaces Break at word boundaries. If the line contains any blanks, (spaces or tabs), within the first width column positions or bytes, the line is broken after the last blank meeting the width constraint. -w, --width=width Use a maximum line length of width columns instead of the default. The default value is 80. OPERANDS The following operand is supported: file A path name of a text file to be folded. If no file operands are specified, the standard input will be used. EXAMPLES 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 ENVIRONMENT VARIABLES See environ(5) for descriptions of the following environment variables that affect the execution of fold: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH. EXIT STATUS The following exit values are returned: 0 All input files were processed successfully. >0 An error occurred. ATTRIBUTES See attributes(5) for descriptions of the following attributes: ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Availability | SUNWcsu | |_____________________________|_____________________________| | CSI | enabled | |_____________________________|_____________________________| | Interface Stability | Commited | |_____________________________|_____________________________| This command conforms to IEEE Std 1003.1-2008. SEE ALSO cut(1), ksh93(1), pr(1), attributes(5), environ(5), standards(5), http://www.opengroup.org/onlinepubs/9699919799/utilities/fold.html NOTES fold(1) and cut(1) can be used to create text files out of files with arbitrary line lengths. fold(1) should be used when the contents of long lines need to be kept contiguous. cut(1) should be used when the number of lines (or records) needs to remain constant. fold(1) 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). SunOS 5.10 Last change: 1 Feb 1995 3