.TH cut "" "" Command
.PC "Select portions of each line of its input"
\fBcut -c\fIlist \fB[\fIfile ...\fB]\fR
.br
\fBcut -f\fIlist \fB[\-s] [\-d \fIchar\^\fB] [\fIfile ...\fB]\fR
.PP
.HS
.SH Options:
.IC "\fB\-c\fIlist\fR"
\fIlist\fR specifies character positions
.IC "\fB\-d\fIchar\fR"
Use \fIchar\fR as field delimiter
.IC "\fB\-f\fIlist\fR"
\fIlist\fR specifies fields
.IC "\fB\-s\fR"
Suppress every line that does not contain a field delimiter
.HE
.B cut
``cuts'' one or pieces out of each line in its input,
and writes the piece or pieces to the standard output.
.I list
specifies the pieces to cut out of each line.
.B cut
reads its input from
.IR file ;
if no
.I file
is named on its command line,
.B cut
reads the standard input.
.PP
A ``piece'' of an input line can be defined either as one or more characters
from fixed positions in the line;
or as one or more fields.
The option
.B \-c
selects characters from fixed positions; you would use this option if you
were cutting up a file each of whose lines was of a fixed length.
The option
.B \-f
selects fields.
A field does not have to have a fixed length, but its end
must be marked by some special character; by default, a white-space character
marks the end of a field.
Option
.B \-d
lets you specify the ``magic character'' that marks the end of a field.
Option
.B \-s
tells
.B cut
to throw away every line that does not contain the field-delimiter character.
By default,
.B cut
will pass through unmodified every line that does not contain the
field delimiter.
.PP
Options
.B \-c
and
.B \-f
are each followed by a
.IR list ,
which describes the pieces that you want from each input line.
A piece is defined as follows:
.IP "\fIN\fR"
A piece consists of a single column or field.
For example, the command
.DM
	cut -f2 /etc/ttytype
.DE
.IP
selects field 2 from file
.BR /etc/ttytype .
.IP "\fIN\-N\fR"
The range of columns or fields.
For example, command
.DM
	cut -c4-12 /etc/ttytype
.DE
.IP
selects columns 4 through 12, inclusive, from file
.BR /etc/ttytype .
.IP \fI-N\fR
Select every column or field from the beginning of the line through
.IR N .
For example, command
.DM
	cut -d\e| -f-3
.DE
.IP
reads the first three fields from the standard input.
.IP \fIN-\fR
Select every column or field from
.I N
through the end of the line.
For example, the command
.DM
	cut -c15-
.DE
.IP
selects every character from character 15 through the end of the line.
.PP
If
.I list
defines more than one piece, the definitions of the pieces must be
separated by commas.
For example, the command
.DM
	cut -c3-5,7-9
.DE
.PP
cuts columns three through five and seven through nine from the standard
input, and writes them onto the standard output.
.PP
.B cut
returns zero on success, one if an error occurred.
.SH Examples
The following cuts column 4 through the end of the line from file
.BR /etc/ttys ,
and writes the cut piece onto the standard output.
In effect, it throws away the first three columns of every line in that file:
.DM
	cut -c4- /etc/ttys
.DE
.PP
You would use this command to display every serial-port device name that that
file contains.
.PP
The next command selects fields one and six from file
.BR /etc/passwd .
(Field one in this file gives a user's login identifier; and field six
gives her home directory.)
Note that fields in this file are delimited by a colon `:'.
.DM
	cut -d: -f1,6 /etc/passwd
.DE
.PP
The final example cuts the first field from the input.
It also explicitly sets the field delimiter to the space character.
You would use this command to clip any trailing white space from data
read from the standard input:
.DM
	cut -f1 -d' '
.DE
.SH "See Also"
.Xr "awk," awk
.Xr "commands," commands
.Xr "paste," paste
.Xr "sed" sed
.SH Notes
.B cut
is copyright \(co 1988,1990 by The Regents of the University of California.
All rights reserved.
