cut - cut out selected fields of each line of a file
cut -b list [-n] [file . . .]
cut -c list <b>[file <b>...]
cut -f list [-d char] [-s] [file . . .]
Use cut 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; if no files are given, the
standard input is used. A file name of ``-'' explicitly refers to
cut processes supplementary code set characters, and recognizes
supplementary code set characters in the char given to the -d option (see
below) according to the locale specified in the LC_CTYPE environment
variable [see LANG on environ(5)]. For special treatment of multibyte
characters, see the -clist option below.
The meanings of the options are:
list A comma-separated list or blank-separated list of positive
numbers and ranges. Ranges have three forms. The first is two
positive integers separated by a hyphen (low-high), which
represents all fields from low to high. The second is a
positive number preceded by a hyphen (-high), which represents
all fields from field 1 to high. The last is a positive number
followed by a hyphen (low-), which represents all fields from
low to the last field, inclusive. Elements in the list can be
repeated, can overlap, and can appear in any order.
-b list Cut based on a list of bytes. Each selected byte will be output
unless the -n option is also specified. Bytes specified need
not be present in the input.
-c list Cut based on a list of characters. Each selected character will
be output. Characters specified need not be present in the
-d The character following -d is the field delimiter (-f option
only). Default is tab. Space or other characters with special
meaning to the shell must be quoted. char may be a
supplementary code set character.
-flist The list following -f is a list of fields assumed to be
separated in the file by a delimiter character (see -d ); for
example, -f1,7 copies the first and seventh field only. Lines
with no field delimiters will be passed through intact (useful
for table subheadings), unless -s is specified. Fields
specified need not be present in the input.
-n Do not split characters. When specified with the -b option, all
characters ending within the range are passed to the output.
-s Suppresses lines with no delimiter characters in case of -f
option. Unless specified, lines with no delimiters will be
passed through untouched.
Either the -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.
cut -d: -f1,5 /etc/passwd
mapping of user IDs to names
name=`who am i | cut -f1 -d" "`
to set name to current login name.
language-specific message file [See LANG on environ(5).]
X/Open CAE Specification(1994)--Commands and Utilities.
UX:cut:ERROR:line too long
A line can have no more than 1023 bytes or fields, or there
is no new-line character.
UX:cut:ERROR:bad list for c/f option
Missing -c or -f option or incorrectly specified list. No
error occurs if a line has fewer fields than the list calls
The list is empty.
Missing char on -d option.
UX:cut:ERROR:cannot handle multiple adjacent backspaces
Adjacent backspaces cannot be processed correctly.
UX:cut:WARNING:cannot open <filename<b>>
Either filename cannot be read or does not exist. If
multiple filenames are present, processing continues.
PPPPaaaaggggeeee 3333 [ Back ]