The cut(1w) utility cuts out bytes
(-b option), characters (-c
option), or character-delimited fields (-f
option) from each line in one or more files, concatenates them, and
writes them to the standard output.
The option-argument list must be a comma-separated list
of positive numbers and ranges. Ranges can be expressed in three
forms. The first is two positive numbers separated by a hyphen
(-)(low-high), which
represents all fields from the first number to the second number.
The second is a positive number preceded by a hyphen
(-high), which represents all fields from field
number 1 to that number. The third is a positive number
followed by a hyphen (low-), which represents
that number to the last field. The elements in the list can be
repeated, overlapped, and specified in any order.
OPTIONS
The cut utility supports the following options:
-b
Cuts based on a list of bytes. Each selected byte is the output
unless the -n option is also specified. It is
not an error to select bytes absent in the input line.
-c
Cuts based on a list of characters. Each selected character is
the output. It is not an error to select characters absent in the
input line.
-d
Sets the field delimiter to the character delim. The
default is the TAB character.
-f
Cuts based on a list of fields, assumed to be separated in the
file by a delimiter character (see the -d
option). Each selected field is the output. Output fields are
separated by a single occurrence of the field-delimiter character.
Lines with no field delimiter are passed through intact unless the
-s option is specified. It is not an error to
select fields absent in the input line.
-n
Does not split characters. When the -n
option is specified with the -b option, each
element in list of the form
low-high (hyphen-separated numbers) is
modified as follows:
If the byte selected by low is not the first byte of a
character, low is decremented to select the first byte of
the character originally selected by low.
If the byte selected by high is not the last byte of a
character, high is decremented to select the last byte of
the character prior to the character originally selected by
high, or zero if there is no prior character.
If the resulting range element has high equal to zero or
low greater than high, the list element is dropped
from list for that input line without causing an error.
Each element in list of the form
low- is treated as above, with high set
to the number of bytes in the current line, not including the
terminating newline character.
Each element in list of the form
-high is treated as above, with low set
to 1.
Each element in list of the form num (a single
number) is treated as above with low set to num and
high set to num.
-s
When used with the -f option, -s
suppresses lines with no delimiter characters. Unless specified,
lines with no delimiters are passed through untouched.