CUT(1) | User Commands | CUT(1) |
cut - cut out selected fields of each line of a file
cut -b list [-n] [file]...
cut -c list [file]...
cut -f list [-d delim] [-s] [file]...
Use the cut utility to cut out columns from a table or fields from each line of a file; in data base parlance, it implements the projection of a relation. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option) or the length can vary from line to line and be marked with a field delimiter character like TAB (-f option). cut can be used as a filter.
Either the -b, -c, or -f option must be specified.
Use grep(1) to make horizontal ``cuts'' (by context) through a file, or paste(1) to put files together column-wise (that is, horizontally). To reorder columns in a table, use cut and paste.
The following options are supported:
list
-b list
-c list
-d delim
-f list
-n
-s
The following operands are supported:
file
See largefile(7) for the description of the behavior of cut when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
Example 1 Mapping user IDs
A mapping of user IDs to names follows:
example% cut -d: -f1,5 /etc/passwd
Example 2 Setting current login name
To set name to current login name:
example$ name=`who am i | cut -f1 -d' '`
See environ(7) for descriptions of the following environment variables that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned:
0
>0
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
CSI | Enabled |
Interface Stability | Standard |
grep(1), paste(1), attributes(7), environ(7), largefile(7), standards(7)
cut: -n may only be used with -b
cut: -d may only be used with -f
cut: -s may only be used with -f
cut: cannot open <file>
cut: no delimiter specified
cut: invalid delimiter
cut: no list specified
cut: invalid range specifier
cut: too many ranges specified
cut: range must be increasing
cut: invalid character in range
cut: internal error processing input
cut: invalid multibyte character
cut: unable to allocate enough memory
April 29, 1999 | OmniOS |