1cut(1)                           User Commands                          cut(1)
2
3
4

NAME

6       cut - cut out selected fields of each line of a file
7

SYNOPSIS

9       cut -b list [-n] [file]...
10
11
12       cut -c list [file]...
13
14
15       cut -f list [-d delim] [-s] [file]...
16
17

DESCRIPTION

19       Use the cut utility to cut out columns from a table or fields from each
20       line of a file; in data base parlance, it implements the projection  of
21       a  relation.  The fields as specified by list can be fixed length, that
22       is, character positions as on a punched card (-c option) or the  length
23       can vary from line to line and be marked with a field delimiter charac‐
24       ter like TAB (-f option). cut can be used as a filter.
25
26
27       Either the -b, -c, or -f option must be specified.
28
29
30       Use grep(1) to make horizontal ``cuts'' (by context) through a file, or
31       paste(1)  to put files together column-wise (that is, horizontally). To
32       reorder columns in a table, use cut and paste.
33

OPTIONS

35       The following options are supported:
36
37       list         A comma-separated  or  blank-character-separated  list  of
38                    integer field numbers (in increasing order), with optional
39                    to indicate ranges (for instance,  1,4,7;  1−3,8;  −5,10
40                    (short  for  1−5,10);  or 3− (short for third through last
41                    field)).
42
43
44       -b list      The  list  following  -b  specifies  byte  positions  (for
45                    instance,  -b1-72  would  pass  the first 72 bytes of each
46                    line). When -b and -n are used together, list is  adjusted
47                    so that no multi-byte character is split.
48
49
50       -c list      The  list  following -c specifies character positions (for
51                    instance, -c1-72 would pass the  first  72  characters  of
52                    each line).
53
54
55       -d delim     The  character  following  -d  is  the field delimiter (-f
56                    option only). Default is tab. Space  or  other  characters
57                    with  special  meaning  to the shell must be quoted. delim
58                    can be a multi-byte character.
59
60
61       -f list      The list following -f is a list of fields  assumed  to  be
62                    separated  in the file by a delimiter character (see -d );
63                    for instance, -f1,7 copies the  first  and  seventh  field
64                    only.  Lines  with  no  field  delimiters  will  be passed
65                    through intact (useful for table subheadings),  unless  -s
66                    is specified.
67
68
69       -n           Do  not  split  characters.  When  -b list and -n are used
70                    together, list is adjusted so that no multi-byte character
71                    is split.
72
73
74       -s           Suppresses  lines  with no delimiter characters in case of
75                    -f option. Unless specified, lines with no delimiters will
76                    be passed through untouched.
77
78

OPERANDS

80       The following operands are supported:
81
82       file     A  path  name of an input file. If no file operands are speci‐
83                fied, or if a file operand is , the standard  input  will  be
84                used.
85
86

USAGE

88       See  largefile(5)  for  the  description  of  the  behavior of cut when
89       encountering files greater than or equal to 2 Gbyte (2^31 bytes).
90

EXAMPLES

92       Example 1 Mapping user IDs
93
94
95       A mapping of user IDs to names follows:
96
97
98         example% cut -d: -f1,5 /etc/passwd
99
100
101
102       Example 2 Setting current login name
103
104
105       To set name to current login name:
106
107
108         example$ name=`who am i | cut -f1 -d' '`
109
110
111

ENVIRONMENT VARIABLES

113       See environ(5) for descriptions of the following environment  variables
114       that  affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
115       and NLSPATH.
116

EXIT STATUS

118       The following exit values are returned:
119
120       0      All input files were output successfully.
121
122
123       >0     An error occurred.
124
125

ATTRIBUTES

127       See attributes(5) for descriptions of the following attributes:
128
129
130
131
132       ┌─────────────────────────────┬─────────────────────────────┐
133       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
134       ├─────────────────────────────┼─────────────────────────────┤
135       │Availability                 │SUNWcsu                      │
136       ├─────────────────────────────┼─────────────────────────────┤
137       │CSI                          │Enabled                      │
138       ├─────────────────────────────┼─────────────────────────────┤
139       │Interface Stability          │Standard                     │
140       └─────────────────────────────┴─────────────────────────────┘
141

SEE ALSO

143       grep(1),  paste(1),  attributes(5),  environ(5),  largefile(5),   stan‐
144       dards(5)
145

DIAGNOSTICS

147       cut: -n may only be used with -b
148
149
150
151
152       cut: -d may only be used with -f
153
154
155
156
157       cut: -s may only be used with -f
158
159
160
161
162       cut: cannot open <file>
163
164           Either  file  cannot  be read or does not exist.  If multiple files
165           are present, processing continues.
166
167
168       cut: no delimiter specified
169
170           Missing delim on -d option.
171
172
173       cut: invalid delimiter
174
175
176
177
178       cut: no list specified
179
180           Missing list on -b, -c, or -f option.
181
182
183       cut: invalid range specifier
184
185
186
187
188       cut: too many ranges specified
189
190
191
192
193       cut: range must be increasing
194
195
196
197
198       cut: invalid character in range
199
200
201
202
203       cut: internal error processing input
204
205
206
207
208       cut: invalid multibyte character
209
210
211
212
213       cut: unable to allocate enough memory
214
215
216
217
218
219
220SunOS 5.11                        29 Apr 1999                           cut(1)
Impressum