672 xargs doesn't support -0
[illumos-gate.git] / usr / src / man / man1 / fold.1
blob6b5301b895dcdab06124ed081f6114f7bb23d63a
1 '\" te
2 .\"  Copyright 1989 AT&T  Copyright (c) 1995, Sun Microsystems, Inc.  All Rights Reserved  Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH FOLD 1 "Feb 1, 1995"
11 .SH NAME
12 fold \- filter for folding lines
13 .SH SYNOPSIS
14 .LP
15 .nf
16 \fBfold\fR [\fB-bs\fR] [\fB-w\fR \fIwidth\fR | \fB-width\fR] [\fIfile\fR]...
17 .fi
19 .SH DESCRIPTION
20 .sp
21 .LP
22 The \fBfold\fR utility is a filter that will fold lines from its input files,
23 breaking the lines to have a maximum of \fIwidth\fR column positions (or bytes,
24 if the \fB-b\fR option is specified). Lines will be broken by the insertion of
25 a NEWLINE character such that each output line (referred to later in this
26 section as a segment) is the maximum width possible that does not exceed the
27 specified number of column positions (or bytes). A line will not be broken in
28 the middle of a character. The behavior is undefined if \fIwidth\fR is less
29 than the number of columns any single character in the input would occupy.
30 .sp
31 .LP
32 If the CARRIAGE-RETURN, BACKSPACE, or TAB characters are encountered in the
33 input, and the \fB-b\fR option is not specified, they will be treated
34 specially:
35 .sp
36 .ne 2
37 .na
38 \fBBACKSPACE \fR
39 .ad
40 .RS 20n
41 The current count of line width will be decremented by one, although the count
42 never will become negative. \fBfold\fR will not insert a NEWLINE character
43 immediately before or after any BACKSPACE character.
44 .RE
46 .sp
47 .ne 2
48 .na
49 \fBCARRIAGE-RETURN \fR
50 .ad
51 .RS 20n
52 The current count of line width will be set to \fB0\fR. \fBfold\fR will not
53 insert a NEWLINE character immediately before or after any CARRIAGE-RETURN
54 character.
55 .RE
57 .sp
58 .ne 2
59 .na
60 \fBTAB \fR
61 .ad
62 .RS 20n
63 Each TAB character encountered will advance the column position pointer to the
64 next tab stop. Tab stops will be at each column position \fIn\fR such that
65 \fIn\fR modulo 8 equals 1.
66 .RE
68 .SH OPTIONS
69 .sp
70 .LP
71 The following options are supported:
72 .sp
73 .ne 2
74 .na
75 \fB\fB-b\fR \fR
76 .ad
77 .RS 20n
78 Counts \fIwidth\fR in bytes rather than column positions.
79 .RE
81 .sp
82 .ne 2
83 .na
84 \fB\fB-s\fR \fR
85 .ad
86 .RS 20n
87 If a segment of a line contains a blank character within the first \fIwidth\fR
88 column positions (or bytes), breaks the line after the last such blank
89 character meeting the width constraints. If there is no blank character meeting
90 the requirements, the \fB-s\fR option will have no effect for that output
91 segment of the input line.
92 .RE
94 .sp
95 .ne 2
96 .na
97 \fB\fB-w\fR \fIwidth\fR\fB|\fR\fB-\fR\fIwidth\fR \fR
98 .ad
99 .RS 20n
100 Specifies the maximum line length, in column positions (or bytes if \fB-b\fR is
101 specified). If \fIwidth\fR is not a positive decimal number, an error is
102 returned. The default value is 80.
105 .SH OPERANDS
108 The following operand is supported:
110 .ne 2
112 \fB\fB\fIfile\fR\fR \fR
114 .RS 9n
115 A path name of a text file to be folded. If no \fIfile\fR operands are
116 specified, the standard input will be used.
119 .SH EXAMPLES
121 \fBExample 1 \fRSubmitting a file of possibly long lines to the line printer
124 An example invocation that submits a file of possibly long lines to the line
125 printer (under the assumption that the user knows the line width of the printer
126 to be assigned by \fBlp\fR(1)):
129 .in +2
131 example% \fBfold -w 132 bigfile | lp\fR
133 .in -2
136 .SH ENVIRONMENT VARIABLES
139 See \fBenviron\fR(5) for descriptions of the following environment variables
140 that affect the execution of \fBfold\fR: \fBLANG\fR, \fBLC_ALL\fR,
141 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
142 .SH EXIT STATUS
145 The following exit values are returned:
147 .ne 2
149 \fB\fB0\fR \fR
151 .RS 7n
152 All input files were processed successfully.
156 .ne 2
158 \fB\fB>0\fR \fR
160 .RS 7n
161 An error occurred.
164 .SH ATTRIBUTES
167 See \fBattributes\fR(5) for descriptions of the following attributes:
172 box;
173 c | c
174 l | l .
175 ATTRIBUTE TYPE  ATTRIBUTE VALUE
177 CSI     enabled
179 Interface Stability     Standard
182 .SH SEE ALSO
185 \fBcut\fR(1), \fBpr\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
186 \fBstandards\fR(5)
187 .SH NOTES
190 \fBfold\fR and \fBcut\fR(1) can be used to create text files out of files with
191 arbitrary line lengths. \fBfold\fR should be used when the contents of long
192 lines need to be kept contiguous. \fBcut\fR should be used when the number of
193 lines (or records) needs to remain constant.
196 \fBfold\fR is frequently used to send text files to line printers that
197 truncate, rather than fold, lines wider than the printer is able to print
198 (usually 80 or 132 column positions).
201 \fBfold\fR may not work correctly if underlining is present.