2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 1999, Sun Microsystems, Inc. All Rights Reserved
4 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
5 .\" 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
6 .\" http://www.opengroup.org/bookstore/.
7 .\" 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.
8 .\" This notice shall appear on any product containing this material.
9 .\" 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.
10 .\" 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.
11 .\" 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]
12 .TH CUT 1 "Apr 29, 1999"
14 cut \- cut out selected fields of each line of a file
18 \fBcut\fR \fB-b\fR \fIlist\fR [\fB-n\fR] [\fIfile\fR]...
23 \fBcut\fR \fB-c\fR \fIlist\fR [\fIfile\fR]...
28 \fBcut\fR \fB-f\fR \fIlist\fR [\fB-d\fR \fIdelim\fR] [\fB-s\fR] [\fIfile\fR]...
34 Use the \fBcut\fR utility to cut out columns from a table or fields from each
35 line of a file; in data base parlance, it implements the projection of a
36 relation. The fields as specified by \fIlist\fR can be fixed length, that is,
37 character positions as on a punched card (\fB-c\fR option) or the length can
38 vary from line to line and be marked with a field delimiter character like TAB
39 (\fB-f\fR option). \fBcut\fR can be used as a filter.
42 Either the \fB-b\fR, \fB-c\fR, or \fB-f\fR option must be specified.
45 Use \fBgrep\fR(1) to make horizontal ``cuts'' (by context) through a file, or
46 \fBpaste\fR(1) to put files together column-wise (that is, horizontally). To
47 reorder columns in a table, use \fBcut\fR and \fBpaste\fR.
51 The following options are supported:
58 A comma-separated or blank-character-separated list of integer field numbers
59 (in increasing order), with optional \fB\(mi\fR to indicate ranges (for
60 instance, \fB1,4,7\fR; \fB1\(mi3,8\fR; \fB\(mi5,10\fR (short for
61 \fB1\(mi5,10\fR); or \fB3\(mi\fR (short for third through last field)).
67 \fB\fB\fR\fB-b\fR \fIlist\fR \fR
70 The \fIlist\fR following \fB-b\fR specifies byte positions (for instance,
71 \fB-b1\fR\fB-72\fR would pass the first 72 bytes of each line). When \fB-b\fR
72 and \fB-n\fR are used together, \fIlist\fR is adjusted so that no multi-byte
79 \fB\fB\fR\fB-c\fR \fIlist\fR \fR
82 The \fIlist\fR following \fB-c\fR specifies character positions (for instance,
83 \fB-c1\fR\fB-72\fR would pass the first 72 characters of each line).
89 \fB\fB\fR\fB-d\fR \fIdelim\fR \fR
92 The character following \fB-d\fR is the field delimiter (\fB-f\fR option only).
93 Default is \fItab\fR. Space or other characters with special meaning to the
94 shell must be quoted. \fIdelim\fR can be a multi-byte character.
100 \fB\fB\fR\fB-f\fR \fIlist\fR \fR
103 The \fIlist\fR following \fB-f\fR is a list of fields assumed to be separated
104 in the file by a delimiter character (see \fB-d\fR ); for instance,
105 \fB-f1\fR\fB,7\fR copies the first and seventh field only. Lines with no field
106 delimiters will be passed through intact (useful for table subheadings), unless
107 \fB-s\fR is specified.
116 Do not split characters. When \fB-b\fR \fIlist\fR and \fB-n\fR are used
117 together, \fIlist\fR is adjusted so that no multi-byte character is split.
126 Suppresses lines with no delimiter characters in case of \fB-f\fR option.
127 Unless specified, lines with no delimiters will be passed through untouched.
133 The following operands are supported:
140 A path name of an input file. If no \fIfile\fR operands are specified, or if a
141 \fIfile\fR operand is \fB\(mi\fR, the standard input will be used.
147 See \fBlargefile\fR(5) for the description of the behavior of \fBcut\fR when
148 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
151 \fBExample 1 \fRMapping user IDs
154 A mapping of user \fBIDs\fR to names follows:
159 example% \fBcut -d: -f1,5 /etc/passwd\fR
165 \fBExample 2 \fRSetting current login name
168 To set \fBname\fR to current login name:
173 example$ \fBname=\(gawho am i | cut -f1 -d' '\(ga\fR
178 .SH ENVIRONMENT VARIABLES
181 See \fBenviron\fR(5) for descriptions of the following environment variables
182 that affect the execution of \fBcut\fR: \fBLANG\fR, \fBLC_ALL\fR,
183 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
187 The following exit values are returned:
194 All input files were output successfully.
209 See \fBattributes\fR(5) for descriptions of the following attributes:
217 ATTRIBUTE TYPE ATTRIBUTE VALUE
221 Interface Stability Standard
227 \fBgrep\fR(1), \fBpaste\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
228 \fBlargefile\fR(5), \fBstandards\fR(5)
233 \fB\fBcut: \fR\fB-n\fR\fB may only be used with \fR\fB-b\fR \fR
243 \fB\fBcut: \fR\fB-d\fR\fB may only be used with \fR\fB-f\fR \fR
253 \fB\fBcut: \fR\fB-s\fR\fB may only be used with \fR\fB-f\fR \fR
263 \fB\fBcut: cannot open \fR\fI<file>\fR \fR
267 Either \fIfile\fR cannot be read or does not exist. If multiple files are
268 present, processing continues.
274 \fB\fBcut: no delimiter specified\fR \fR
278 Missing \fIdelim\fR on \fB-d\fR option.
284 \fB\fBcut: invalid delimiter\fR \fR
294 \fB\fBcut: no \fIlist\fR\fR\fB specified\fR \fR
298 Missing \fIlist\fR on \fB-b\fR, \fB-c\fR, or \fB-f\fR option.
304 \fB\fBcut: invalid range specifier\fR \fR
314 \fB\fBcut: too many ranges specified\fR \fR
324 \fB\fBcut: range must be increasing\fR \fR
334 \fB\fBcut: invalid character in range\fR \fR
344 \fB\fBcut: internal error processing input\fR \fR
354 \fB\fBcut: invalid multibyte character\fR \fR
364 \fB\fBcut: unable to allocate enough memory\fR \fR