Index Index for
Section 1
Index Alphabetical
listing for F
Bottom of page Bottom of
page

fold(1)

NAME

fold - Breaks or wraps lines in a file

SYNOPSIS

fold [-bs] [-w width | -width] [file...] The fold command wraps lines in the specified files. If a file is not specified, standard input is the default. All lines are wrapped to meet the maximum width specified.

STANDARDS

Interfaces documented on this reference page conform to industry standards as follows: fold: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags.

OPTIONS

-b Specifies that width be counted in bytes rather than in column positions. Using the -b option does not limit lines to LINE_MAX bytes. -s Breaks (or wraps) a line if a segment of the line contains a blank character in the first width column position (or bytes). This enables the line to meet width constraints. If a blank character is not in the correct width column position, the -s option has no affect on that input line. -w width or -width Specifies the maximum width to use when lines are wrapped in column positions (or bytes if the -b option is specified). Either -w width or -width is acceptable input where width is the number of column positions (or bytes). The default value is 80.

DESCRIPTION

The fold command is a filter that wraps lines from the specified input files or standard input to a maximum of width (or bytes, if the -b option is specified). The fold command wraps lines by inserting a newline character into the output so that each output line is the maximum column positions or bytes specified. A line cannot be broken in the middle of a character. The fold command is often used to send text files to line printers that truncate, rather than wrap, lines wider than the printer is able to print (usually 80 or 132 column positions). If the <backspace>, <tab>, or <carriage return> characters are encountered in the input, and the -b option is not specified, these characters are treated specially: <backspace> The current count of line width is decremented by one, although the count never becomes negative. The fold command does not insert a newline character immediately before or after any backspace character. <tab> Each tab character encountered advances the column position pointer to the position of the next tab stop. Tab stops are at each column position number, such that number modulo 8 equals 1. <carriage-return> The current count of the line width is set to zero (0). The fold command does not insert a newline immediately before or after any carriage return. [Tru64 UNIX] The fold command possibly affects underlining in a file.

EXIT STATUS

The fold command returns the following values: 0 All input files were successfully processed. 1 [Tru64 UNIX] A usage error occurred. 2 [Tru64 UNIX] An input file cannot be opened. The fold command continues processing the other input files specified on the command line.

EXAMPLES

The fold command can be used to prepare files to be joined side-by-side with the paste command. For example, the contents of two files, az and AZ follows: aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ To display the az and AZ files side-by-side, use the following command line: fold -w 32 az > az2; fold -w 32 AZ > AZ2; paste -d" " az2 AZ2 Executing the previous command line results in the following output: aaaa bbbb cccc dddd eeee ffff gg AAAA BBBB CCCC DDDD EEEE FFFF GG gg hhhh iiii jjjj kkkk llll mmmm GG HHHH IIII JJJJ KKKK LLLL MMMM nnnn oooo pppp qqqq rrrr ssss tt NNNN OOOO PPPP QQQQ RRRR SSSS TT tt uuuu vvvv wwww xxxx yyyy zzzz TT UUUU VVVV WWWW XXXX YYYY ZZZZ

ENVIRONMENT VARIABLES

The following environment variables affect the execution of fold: LANG Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if none of the variables had been defined. LC_ALL If set to a non-empty string value, overrides the values of all the other internationalization variables. LC_CTYPE Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments) and for the determination of the width in column positions each character would occupy on a constant- width font output device. LC_MESSAGES Determines the locale for the format and contents of diagnostic messages written to standard error. NLSPATH Determines the location of message catalogues for the processing of LC_MESSAGES.

SEE ALSO

Commands: cut(1), expand(1), paste(1) Standards: standards(5)

Index Index for
Section 1
Index Alphabetical
listing for F
Top of page Top of
page