Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 exptools 1/6/84; site ihuxx.UUCP Path: utzoo!watmath!clyde!burl!mgnetp!ihnp4!ihuxx!ignatz From: ignatz@ihuxx.UUCP (Dave Ihnat, Chicago, IL) Newsgroups: net.sources Subject: Re: re-write of the Unix 'cut' command Message-ID: <821@ihuxx.UUCP> Date: Tue, 14-Aug-84 14:13:18 EDT Article-I.D.: ihuxx.821 Posted: Tue Aug 14 14:13:18 1984 Date-Received: Wed, 15-Aug-84 01:42:17 EDT References: <811@ihuxx.UUCP> Organization: AT&T Bell Labs, Naperville, IL Lines: 99 Even though I posted both source and man page for 'cut' as a 'shar' archive, several people complained they only got the source. (?) So, following, is simply the man page, as announced in net.unix,net.unix-wizards, and net.micro. Dave Ihnat ihuxx!ignatz -----------------------cut (heh,heh)------------------------- .TH CUT 1 "" .SH NAME cut \- cut out selected fields of each line of a file .SH SYNOPSIS \fBcut -c\fPlist [file1 file2 ...] .br \fBcut -f\fPlist [\fB-d\fP char] [\fB-s\fP] [file1 file2 ...] .SH DESCRIPTION Use \fIcut\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 \fIlist\fP 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 \fItab\fP (\fB\-f\fP option). \fICut\fP can be used as a filter; if no files are given, the standard input is used. .PP The meanings of the options are: .TP .75 \fIlist\fP A comma-separated list of integer field numbers (in increasing order), with optional \- to indicate ranges as in the \fB\-o\fP option of \fInroff/troff\fP for page ranges; e.g., \fB1,4,5\fP\; \fB1\-3,8\fP\; \fB\-5,10\fP (short for \fB1\-5,10\P); or \fB3\-\fP (short for third through last field). .TP \fB\-c\fIlist\fR The \fIlist\fP following \fB\-c\fP (no space) specifies character positions (e.g., \fB\-c1\-72\fP would pass the first 72 characters of each line). .TP \fB\-f\fIlist\fR The \fIlist\fP following \fB\-f\fP is a list of fields assumed to be separated in the file by a delimiter character (see \fB\-d\fP); e.g., \fB\-f1,7\fP copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless \fB\-s\fP is specified. .TP \fB\-d\fIchar\fR The character following \fB\-d\fP is the field delimiter (\fB\-f\fP option only). Default is \fItab\fP. Space or other characters with special meaning to the shell must be quoted. .TP \fB\-s\fP Supresses lines with no delimiter characters in case of \fB\-f\fP option. Unless specified, lines with no delimiters will be passed through untouched. .PP Either the \fB\-c\fP or \fB\-f\fP option must be specified. .SH HINTS Use \fIgrep\fP(1) to make horizontal "cuts" (by context) through a file or \fIpaste\fP(1) to put files together column\-wise (i.e., horizontally). To reorder columns in a table, use \fIcut\fP and \fIpaste\fP. .SH EXAMPLES .TP 2.25 cut -d: -f1,5 /etc/passwd mapping of user IDs to names .TP name\=\`who am i\|cut \-f1 \-d\"\ \"\` to set \fBname\fP to current login name .SH DIAGNOSTICS .TP 2.0 \fIline too long\fP A line can have no more than 511 characters or fields. .TP \fIbad list for c/f option\fP Missing \fB\-c\fP or \fB\-f\fP option or incorrectly specified \fIlist\fP. No error occurs if a line has fewer fields than the \fIlist\fP calls for. .TP \fIno fields\fP The \fIlist\fP is empty. .SH SEE ALSO grep(1),paste(1). .SH CAVEATS This program is a complete rewrite of the Bell Laboratories command of the same name; no part of the original source or manual is included. Therefore, you may feel free to use it, and its source, without violation of \fPany\fP contract agreements. However, I retain the copyright in order to specify it remain available for use by all and sundry, without cost. Feel free to modify as necessary, although I went to great pains to recreate the behavior of the original command; I would suggest this congruence be maintained. .PP Along the same lines, although I've made a reasonable effort to test the more arcane behavior of the original \fIcut\fP and reproduce it, there are no guarantees. I remain in no way liable for any loss, either explicit or incidental, that may be incurred through use of this command. I do ask that any bugs (and, hopefully, fixes) be reported back to me as encountered. \- David M. Ihnat, ihuxx!ignatz