1fold(1) User Commands fold(1)
2
3
4
6 fold - filter for folding lines
7
9 fold [-bs] [-w width | -width] [file]...
10
11
13 The fold utility is a filter that will fold lines from its input files,
14 breaking the lines to have a maximum of width column positions (or
15 bytes, if the -b option is specified). Lines will be broken by the
16 insertion of a NEWLINE character such that each output line (referred
17 to later in this section as a segment) is the maximum width possible
18 that does not exceed the specified number of column positions (or
19 bytes). A line will not be broken in the middle of a character. The
20 behavior is undefined if width is less than the number of columns any
21 single character in the input would occupy.
22
23
24 If the CARRIAGE-RETURN, BACKSPACE, or TAB characters are encountered in
25 the input, and the -b option is not specified, they will be treated
26 specially:
27
28 BACKSPACE The current count of line width will be decremented
29 by one, although the count never will become nega‐
30 tive. fold will not insert a NEWLINE character
31 immediately before or after any BACKSPACE charac‐
32 ter.
33
34
35 CARRIAGE-RETURN The current count of line width will be set to 0.
36 fold will not insert a NEWLINE character immedi‐
37 ately before or after any CARRIAGE-RETURN charac‐
38 ter.
39
40
41 TAB Each TAB character encountered will advance the
42 column position pointer to the next tab stop. Tab
43 stops will be at each column position n such that n
44 modulo 8 equals 1.
45
46
48 The following options are supported:
49
50 -b Counts width in bytes rather than column positions.
51
52
53 -s If a segment of a line contains a blank character
54 within the first width column positions (or bytes),
55 breaks the line after the last such blank character
56 meeting the width constraints. If there is no blank
57 character meeting the requirements, the -s option
58 will have no effect for that output segment of the
59 input line.
60
61
62 -w width|-width Specifies the maximum line length, in column posi‐
63 tions (or bytes if -b is specified). If width is
64 not a positive decimal number, an error is
65 returned. The default value is 80.
66
67
69 The following operand is supported:
70
71 file A path name of a text file to be folded. If no file operands
72 are specified, the standard input will be used.
73
74
76 Example 1 Submitting a file of possibly long lines to the line printer
77
78
79 An example invocation that submits a file of possibly long lines to the
80 line printer (under the assumption that the user knows the line width
81 of the printer to be assigned by lp(1)):
82
83
84 example% fold -w 132 bigfile | lp
85
86
87
89 See environ(5) for descriptions of the following environment variables
90 that affect the execution of fold: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
91 and NLSPATH.
92
94 The following exit values are returned:
95
96 0 All input files were processed successfully.
97
98
99 >0 An error occurred.
100
101
103 See attributes(5) for descriptions of the following attributes:
104
105
106
107
108 ┌─────────────────────────────┬─────────────────────────────┐
109 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
110 ├─────────────────────────────┼─────────────────────────────┤
111 │Availability │SUNWcsu │
112 ├─────────────────────────────┼─────────────────────────────┤
113 │CSI │enabled │
114 ├─────────────────────────────┼─────────────────────────────┤
115 │Interface Stability │Standard │
116 └─────────────────────────────┴─────────────────────────────┘
117
119 cut(1), pr(1), attributes(5), environ(5), standards(5)
120
122 fold and cut(1) can be used to create text files out of files with
123 arbitrary line lengths. fold should be used when the contents of long
124 lines need to be kept contiguous. cut should be used when the number of
125 lines (or records) needs to remain constant.
126
127
128 fold is frequently used to send text files to line printers that trun‐
129 cate, rather than fold, lines wider than the printer is able to print
130 (usually 80 or 132 column positions).
131
132
133 fold may not work correctly if underlining is present.
134
135
136
137SunOS 5.11 1 Feb 1995 fold(1)