CUT(1) | User Commands | CUT(1) |
cut
—
cut |
-b list
[-nN ] [-r
reclen] [file]... |
cut |
-c list
[-N ] [-r
reclen] [file]... |
cut |
-f list
[-s ] [-d
delim] [-D
ldelim] [file]... |
cut
utility to cut out columns from a table or
fields from each line of a file. In database 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 such as 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(1).
-b
list,
--bytes
=list-b
specifies byte positions (for instance, -b
1-72 would pass the first 72 bytes of each line).
When -b
and -n
are used
together, list is adjusted so that no multi-byte character is split.-c
list,
--characters
=list-c
specifies character positions (for instance, -c
1-72 would pass the first 72 characters of each
line).-d
delim,
--delimiter
=delim-d
is the field delimiter
(-f
option only); the
default is the TAB character. Space or other characters with special
meaning to the shell must be quoted. delim can be a multi-byte
character.-f
list,
--fields
=list-f
is a
list of fields assumed to be separated in the file by a delimiter
character (see -d
); for instance,
-f
1,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.-n
,
--split
, --nosplit
-b
option. The default is to split characters and
this can be disabled with the -n
or
--nosplit
flag. Unless specified, lines with no
delimiters will be passed through untouched.-r
reclen, -R
reclen,
--reclen
=reclen-b
or -c
options.-s
,
--suppress
,
--only-delimited
-f
option only).-D
ldelim,
--line-delimiter
=ldelim,
--output-delimiter
=ldelim-f
option is set to
ldelim. The default is the newline character.-N
,
--newline
, --nonewline
-b
or -c
options.
This is on by default; -N
turns it off and is the
same as specifying --nonewline
.In the above options, list is a comma-separated or blank-character-separated list of integer field, byte or character numbers (in increasing order), with optional − to indicate ranges (for instance, 1,4,7; 1−3,8; −5,10 (short for 1−5,10); or 3− (short for third through last field). )
A mapping of user IDs to names follows:
$ cut -d: -f1,5 /etc/passwd
To set name to current login name:
$ name=`who am i | cut -f1 -d' '`
cut
:
LANG
, LC_ALL
,
LC_CTYPE
, LC_MESSAGES
,
LC_NUMERIC
, and NLSPATH
.
cut
is
Committed. The output of cut
is
Committed.
February 9, 2021 | illumos |