.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 ` ` .TH CUT 1 .SH NAME cut \- cut out selected fields of each line of a file .SH SYNOPSIS \fBcut \-c\fP\^list [\|file1 file2 ...] .br \fBcut \-f\fP\^list [\fB\-d\fP\|char\|] [\fB\-s\fP] [\|file1 file2 ...] .SH DESCRIPTION Use .I cut\^ 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 (\fB\-c\fP option), or the length can vary from line to line and be marked with a field delimiter character like .I tab\^ (\fB\-f\fP option). .I Cut\^ can be used as a filter; if no files are given, the standard input is used. .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 \fB\-\fP to indicate ranges as in the .B \-o option of .IR nroff / troff for page ranges; e.g., .BR 1,4,7 ; .BR 1\-3,8 ; .B \-5,10 (short for \fB1\-5,10\fP); or .B 3\- (short for third through last field). .TP \fB\-c\fP\^\fIlist\fP The .I list\^ following .B \-c (no space) specifies character positions (e.g., .B \-c1\-72 would pass the first 72 characters of each line). .TP \fB\-f\fP\^\fIlist\fP The \fIlist\fP following .B \-f is a list of fields assumed to be separated in the file by a delimiter character (see .B \-d ); e.g. , .B \-f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless .B \-s is specified. .TP \fB\-d\fP\^\fIchar\fP The character following .B \-d is the field delimiter (\c .B \-f option only). Default is .IR tab . Space or other characters with special meaning to the shell must be quoted. .TP .B \-s Suppresses lines with no delimiter characters in case of .B \-f option. Unless specified, lines with no delimiters will be passed through untouched. .PP Either the .B \-c or .B \-f option must be specified. .SH HINTS Use .IR grep (1) to make horizontal ``cuts'' (by context) through a file, or .IR paste (1) to put files together column-wise (i.e., horizontally). To reorder columns in a table, use .I cut\^ and .IR paste . .SH EXAMPLES .TP 2.25i cut \-d: \-f1,5 /etc/passwd mapping of user \s-1ID\s0s to names .TP name=\*`who am i | cut \-f1 \-d" "\*` to set .B name to current login name. .SH DIAGNOSTICS .PP .TP 1.25i .I "line too long\^" A line can have no more than 511 characters or fields. .TP .I "bad list for c\|/\|f option\^" Missing .B \-c or .B \-f option or incorrectly specified .IR list . No error occurs if a line has fewer fields than the .I list\^ calls for. .TP .I "no fields\^" The .I list\^ is empty. .SH SEE ALSO grep(1), paste(1). .\" @(#)cut.1 5.2 of 5/18/82