'\"macro stdmacro
.if n .pH g1.cut @(#)cut	40.3 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} cut 1 "Directory and File Management Utilities" "\&"
.if \nX=1 .ds x} cut 1 "Directory and File Management Utilities"
.if \nX=2 .ds x} cut 1 "" "\&"
.if \nX=3 .ds x} cut "" "" "\&"
.TH \*(x}
.if t .ds ' \h@.05m@\s+4\v@.333m@\'\v@-.333m@\s-4\h@.05m@
.if n .ds ' '
.if t .ds ` \h@.05m@\s+4\v@.333m@\`\v@-.333m@\s-4\h@.05m@
.if n .ds ` `
.SH NAME
\f4cut\f1 \- cut out selected fields of each line of a file
.SH SYNOPSIS
\f4cut \-c\f2\^list\fP [\|\f2file\fP ...]
.br
\f4cut \-f\f2\^list\fP [\-d\fP\|char\|\fP] [\f2\-s\fP] [\|\f2file\fP ...]
.SH DESCRIPTION
Use
\f4cut\fP
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
.I list\^
can be fixed length,
i.e., character positions as on a punched card
(\f4\-c\fP option) or the length can vary from line to line
and be marked with a field delimiter character like
.I tab\^
(\f4\-f\fP option).
\f4cut\fP
can be used as a filter;
if no files are given, the standard input is used.
In addition,
a file name of
\f1``\f4\-\f1''
explicitly refers to standard input.
.PP
The meanings of the options are:
.br
.TP "\w'\-d\ char\ \ 'u"
.I list\^
A comma-separated 
list of integer field numbers (in increasing order),
with optional \f4\-\fP to indicate ranges
[e.g.,
\f41,4,7\f1;
\f41\-3,8\f1;
\f4\-5,10\f1
(short for \f41\-5,10\fP); or
\f43\-\f1
(short for third through last field)].
.TP
\f4\-c\fP\^\f2list\fP
The
.I list\^
following 
\f4\-c\f1
(no space) specifies character
positions (e.g.,
\f4\-c1\-72\f1
would pass the first 72 characters
of each line).
.TP
\f4\-f\fP\^\f2list\fP
The \f2list\fP following 
\f4\-f\f1
is a list of fields
assumed to be separated in the file by a delimiter character (see 
\f4\-d\f1
);
e.g.,
\f4\-f1,7\f1
copies the first and seventh field only.
Lines with no field delimiters will be passed through intact (useful
for table subheadings), unless 
\f4\-s\f1
is specified.
.TP
\f4\-d\fP\^\f2char\fP
The character following 
\f4\-d\f1
is the field delimiter
(\c
\f4\-f\f1
option only).
Default is
.IR tab .
Space or other characters with special meaning to the shell must be quoted.
.TP
\f4\-s\f1
Suppresses lines with no delimiter characters in case of
\f4\-f\f1
option.
Unless specified, lines with no delimiters will be passed through untouched.
.PP
Either the
\f4\-c\f1
or 
\f4\-f\f1
option must be specified.
.PP
Use
\f4grep\fP(1)
to make horizontal ``cuts''
(by context) through a file, or
\f4paste\fP(1)
to put files together column-wise
(i.e., horizontally).
To reorder columns in a table, use
\f4cut\fP
and
\f4paste\fP.
.SH EXAMPLES
.TP 2.25i
\f4cut \-d: \-f1,5 /etc/passwd\f1
mapping of user \s-1ID\s0s to names
.TP
\f4name=\(gawho am i | cut \-f1 \-d" "\(ga\f1
to set 
\f4name\f1
to current login
name.
.SH DIAGNOSTICS
.PP
.TP 1.25i
\f4I "\s-1ERROR\s0:  line too long\^"
A line can have no more than 1023 characters or fields,
or there is no new-line character.
.TP
\f4"\s-1ERROR\s0:  bad list for c\|/\|f option\^"\f1
Missing 
\f4\-c\f1
or 
\f4\-f\f1
option or incorrectly specified
.IR list\^ .
No error occurs if a line has fewer fields than the
.I list\^
calls for.
.TP
\f4"\s-1ERROR\s0:  no fields\^"\f1
The
.I list\^
is empty.
.TP
\f4"\s-1ERROR\s0:  no delimeter\^"\f1
Missing
.I char\^
on
\f4\-d\f1
option.
.TP
\f4"\s-1ERROR\s0:  cannot handle multiple adjacent backspaces\^"\f1
Adjacent backspaces cannot be processed correctly.
.TP
\f4"\s-1WARNING\s0:  cannot open <filename>\^"\f1
Either
.I filename\^
cannot be read or does not exist.
If multiple filenames are present, prcessing continues.
.SH SEE ALSO
\f4grep\fP(1),
\f4paste\fP(1).
.\"	@(#)cut.1	6.3 of 9/2/83
.Ee
