cut(1) User Commands cut(1)NAMEcut - cut out selected fields of each line of a file
SYNOPSIS
/usr/bin/cut
/usr/bin/cut [-options] [file ...]
ksh93
cut [-options] [file ...]
DESCRIPTIONcut cuts bytes, characters, or character-delimited fields from one or
more files, and concatenates them on standard output.
The option argument list is a comma-separated or blank-separated list
of positive numbers and ranges. Ranges can be of three forms. The first
is two positive integers separated by a hyphen (low-high), which repre‐
sents all fields from low to high. The second is a positive number pre‐
ceded 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.
The order of the output is that of the input.
One and only one of -b, -c, or -f options must be specified.
If no file is given, or if the file is -, cut cuts from standard input.
The start of the file is defined as the current offset.
OPTIONS
The following options are supported:
-b
--bytes=list
Cut based on a list of bytes.
-c
--characters=list
Cut based on a list of characters.
-d
--delimiter=delim
The field character for the -f option is set to delim. The default
is the TAB character.
-f
--fields=list
Cut based on fields separated by the delimiter character specified
with the -d option.
-n
--nosplit
Do not split characters.
-R | r
--reclen=reclen
If reclen > 0, the input will be read as fixed length records of
length reclen when used with the -b or -c option.
-s
--suppress|only-delimited
Suppress lines with no delimiter characters, when used with the
-foption. By default, lines with no delimiters are passed in
untouched.
-D
--line-delimeter|output-delimiter=ldelim
The line delimiter character for the -f option is set to ldelim.
The default is the NEWLINE character.
-N
--nonewline
Do not output NEWLINEs at end of each record when used with the -b
or -c option.
--man
--html
--nroff
Print built-in manual page in either plain text, HTML or nroff for‐
mat.
--help
Print basic help information.
--version
Print version information.
OPERANDS
The following operands are supported:
file A path name of an input file. If no file operands are speci‐
fied, or if a file operand is -, the standard input will be
used
USAGE
See largefile(5) for the description of the behavior of cut when
encountering files greater than or equal to 2 Gbyte (2^31 bytes).
EXAMPLES
Example 1 Mapping user IDs
A mapping of user IDs to names follows:
example% cut -d: -f1,5 /etc/passwd
Example 2 Setting the Current login name
To set name to current login name:
example$ name=$(who am i | cut-f1 -d' ')
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables
that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were output successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Availability │SUNWcs │
├─────────────────────────────┼─────────────────────────────┤
│CSI │Enabled │
├─────────────────────────────┼─────────────────────────────┤
│Interface Stability │Committed │
├─────────────────────────────┼─────────────────────────────┤
│Standard │See standards(5). │
└─────────────────────────────┴─────────────────────────────┘
SEE ALSOgrep(1), ksh93(1), paste(1), attributes(5), environ(5), largefile(5),
standards(5)SunOS 5.11 29 Nov 2009 cut(1)