teach manpages about largefile's demise
[unleashed.git] / share / man / man1 / cut.1
blob1f6275598a546f7dbe147ee3a3d5f89d22b4debc
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
45 .\" Copyright (c) 1999, Sun Microsystems, Inc.  All Rights Reserved
46 .\"
47 .TH CUT 1 "Apr 29, 1999"
48 .SH NAME
49 cut \- cut out selected fields of each line of a file
50 .SH SYNOPSIS
51 .LP
52 .nf
53 \fBcut\fR \fB-b\fR \fIlist\fR [\fB-n\fR] [\fIfile\fR]...
54 .fi
56 .LP
57 .nf
58 \fBcut\fR \fB-c\fR \fIlist\fR [\fIfile\fR]...
59 .fi
61 .LP
62 .nf
63 \fBcut\fR \fB-f\fR \fIlist\fR [\fB-d\fR \fIdelim\fR] [\fB-s\fR] [\fIfile\fR]...
64 .fi
66 .SH DESCRIPTION
67 .sp
68 .LP
69 Use the \fBcut\fR utility to cut out columns from a table or fields from each
70 line of a file; in data base parlance, it implements the projection of a
71 relation. The fields as specified by \fIlist\fR can be fixed length, that is,
72 character positions as on a punched card (\fB-c\fR option) or the length can
73 vary from line to line and be marked with a field delimiter character like TAB
74 (\fB-f\fR option). \fBcut\fR can be used as a filter.
75 .sp
76 .LP
77 Either the \fB-b\fR, \fB-c\fR, or \fB-f\fR option must be specified.
78 .sp
79 .LP
80 Use \fBgrep\fR(1) to make horizontal ``cuts'' (by context) through a file, or
81 \fBpaste\fR(1) to put files together column-wise (that is, horizontally). To
82 reorder columns in a table, use \fBcut\fR and \fBpaste\fR.
83 .SH OPTIONS
84 .sp
85 .LP
86 The following options are supported:
87 .sp
88 .ne 2
89 .na
90 \fB\fIlist\fR \fR
91 .ad
92 .RS 13n
93 A comma-separated or blank-character-separated list of integer field numbers
94 (in increasing order), with optional \fB\(mi\fR to indicate ranges (for
95 instance, \fB1,4,7\fR; \fB1\(mi3,8\fR; \fB\(mi5,10\fR (short for
96 \fB1\(mi5,10\fR); or \fB3\(mi\fR (short for third through last field)).
97 .RE
99 .sp
100 .ne 2
102 \fB\fB\fR\fB-b\fR \fIlist\fR \fR
104 .RS 13n
105 The \fIlist\fR following \fB-b\fR specifies byte positions (for instance,
106 \fB-b1\fR\fB-72\fR would pass the first 72 bytes of each line). When \fB-b\fR
107 and \fB-n\fR are used together, \fIlist\fR is adjusted so that no multi-byte
108 character is split.
112 .ne 2
114 \fB\fB\fR\fB-c\fR \fIlist\fR \fR
116 .RS 13n
117 The \fIlist\fR following \fB-c\fR specifies character positions (for instance,
118 \fB-c1\fR\fB-72\fR would pass the first 72 characters of each line).
122 .ne 2
124 \fB\fB\fR\fB-d\fR \fIdelim\fR \fR
126 .RS 13n
127 The character following \fB-d\fR is the field delimiter (\fB-f\fR option only).
128 Default is \fItab\fR. Space or other characters with special meaning to the
129 shell must be quoted. \fIdelim\fR can be a multi-byte character.
133 .ne 2
135 \fB\fB\fR\fB-f\fR \fIlist\fR \fR
137 .RS 13n
138 The \fIlist\fR following \fB-f\fR is a list of fields assumed to be separated
139 in the file by a delimiter character (see \fB-d\fR ); for instance,
140 \fB-f1\fR\fB,7\fR copies the first and seventh field only. Lines with no field
141 delimiters will be passed through intact (useful for table subheadings), unless
142 \fB-s\fR is specified.
146 .ne 2
148 \fB\fB-n\fR \fR
150 .RS 13n
151 Do not split characters. When \fB-b\fR \fIlist\fR and \fB-n\fR are used
152 together, \fIlist\fR is adjusted so that no multi-byte character is split.
156 .ne 2
158 \fB\fB-s\fR \fR
160 .RS 13n
161 Suppresses lines with no delimiter characters in case of \fB-f\fR option.
162 Unless specified, lines with no delimiters will be passed through untouched.
165 .SH OPERANDS
168 The following operands are supported:
170 .ne 2
172 \fB\fIfile\fR \fR
174 .RS 9n
175 A path name of an input file. If no \fIfile\fR operands are specified, or if a
176 \fIfile\fR operand is \fB\(mi\fR, the standard input will be used.
179 .SH EXAMPLES
181 \fBExample 1 \fRMapping user IDs
184 A mapping of user \fBIDs\fR to names follows:
187 .in +2
189 example% \fBcut -d: -f1,5 /etc/passwd\fR
191 .in -2
195 \fBExample 2 \fRSetting current login name
198 To set \fBname\fR to current login name:
201 .in +2
203 example$ \fBname=\(gawho am i | cut -f1 -d' '\(ga\fR
205 .in -2
208 .SH ENVIRONMENT VARIABLES
211 See \fBenviron\fR(5) for descriptions of the following environment variables
212 that affect the execution of \fBcut\fR: \fBLANG\fR, \fBLC_ALL\fR,
213 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
214 .SH EXIT STATUS
217 The following exit values are returned:
219 .ne 2
221 \fB\fB0\fR \fR
223 .RS 7n
224 All input files were output successfully.
228 .ne 2
230 \fB\fB>0\fR \fR
232 .RS 7n
233 An error occurred.
236 .SH ATTRIBUTES
239 See \fBattributes\fR(5) for descriptions of the following attributes:
244 box;
245 c | c
246 l | l .
247 ATTRIBUTE TYPE  ATTRIBUTE VALUE
249 CSI     Enabled
251 Interface Stability     Standard
254 .SH SEE ALSO
257 \fBgrep\fR(1), \fBpaste\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
258 \fBstandards\fR(5)
259 .SH DIAGNOSTICS
261 .ne 2
263 \fB\fBcut: \fR\fB-n\fR\fB may only be used with \fR\fB-b\fR \fR
265 .sp .6
266 .RS 4n
271 .ne 2
273 \fB\fBcut: \fR\fB-d\fR\fB may only be used with \fR\fB-f\fR \fR
275 .sp .6
276 .RS 4n
281 .ne 2
283 \fB\fBcut: \fR\fB-s\fR\fB may only be used with \fR\fB-f\fR \fR
285 .sp .6
286 .RS 4n
291 .ne 2
293 \fB\fBcut: cannot open \fR\fI<file>\fR \fR
295 .sp .6
296 .RS 4n
297 Either \fIfile\fR cannot be read or does not exist.  If multiple files are
298 present, processing continues.
302 .ne 2
304 \fB\fBcut: no delimiter specified\fR \fR
306 .sp .6
307 .RS 4n
308 Missing \fIdelim\fR on \fB-d\fR option.
312 .ne 2
314 \fB\fBcut: invalid delimiter\fR \fR
316 .sp .6
317 .RS 4n
322 .ne 2
324 \fB\fBcut: no \fIlist\fR\fR\fB specified\fR \fR
326 .sp .6
327 .RS 4n
328 Missing \fIlist\fR on \fB-b\fR, \fB-c\fR, or \fB-f\fR option.
332 .ne 2
334 \fB\fBcut: invalid range specifier\fR \fR
336 .sp .6
337 .RS 4n
342 .ne 2
344 \fB\fBcut: too many ranges specified\fR \fR
346 .sp .6
347 .RS 4n
352 .ne 2
354 \fB\fBcut: range must be increasing\fR \fR
356 .sp .6
357 .RS 4n
362 .ne 2
364 \fB\fBcut: invalid character in range\fR \fR
366 .sp .6
367 .RS 4n
372 .ne 2
374 \fB\fBcut: internal error processing input\fR \fR
376 .sp .6
377 .RS 4n
382 .ne 2
384 \fB\fBcut: invalid multibyte character\fR \fR
386 .sp .6
387 .RS 4n
392 .ne 2
394 \fB\fBcut: unable to allocate enough memory\fR \fR
396 .sp .6
397 .RS 4n