home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource5
/
329_01
/
cut.doc
< prev
next >
Wrap
Text File
|
1988-12-09
|
4KB
|
199 lines
Page 1 (last mod. 8/19/84)
CUT(1) UNIX 4.0 CUT(1)
NAME
cut - cut out selected fields of each line of a file
SYNOPSIS
cut -clist [file1 file2 ...]
cut -flist [-d char] [-s] [file1 file2 ...]
DESCRIPTION
Use 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 list
can be fixed length, i.e., character positions as on a
punched card (-c option), or the length can vary from line
to line and be marked with a field delimiter character like
tab (-f option). Cut can be used as a filter; if no files
are given, the standard input is used.
The meanings of the options are:
list
A comma-separated list of integer field numbers (in
increasing order), with optional - to indicate ranges as in
the -o option of nroff/troff for page ranges; e.g., 1,4,5;
1-3,8; -5,10 (short for 1-5,10P); or 3- (short for third
through last field).
-clist
The list following -c (no space) specifies character
positions (e.g., -c1-72 would pass the first 72 characters
of each line).
-flist
The list following -f is a list of fields assumed to be
separated in the file by a delimiter character (see -d);
e.g., -f1,7 copies the first and seventh field only. Lines
with no field delimiters will be passed through intact
(useful for table subheadings), unless -s is specified.
-dchar
The character following -d is the field delimiter (-f
option only). Default is tab. Space or other characters
with special meaning to the shell must be quoted.
-s
Supresses lines with no delimiter characters in case of -f
option. Unless specified, lines with no delimiters will be
passed through untouched.
Either the -c or -f option must be specified.
HINTS
Use grep(1) to make horizontal "cuts" (by context) through a
Page 1 (last mod. 8/19/84)
CUT(1) UNIX 4.0 CUT(1)
file or paste(1) to put files together column-wise (i.e.,
horizontally). To reorder columns in a table, use cut and
paste.
EXAMPLESS
cut -d: -f1,5 /etc/passwd
mapping of user IDs to names
name=`who am i | cut -f1 -d:`
to set name to current login name
DIAGNOSTICS
line too long
A line can have no more than 511 characters or fields.
bad list for c/f option
Missing -c or -f option or incorrectly specified list. No
error occurs if a line has fewer fields than the list
calls for.
no fields
The list is empty.
SEE ALSO
grep(1),paste(1).
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 any 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.
Along the same lines, although I've made a reasonable effort
to test the more arcane behavior of the original cut 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
Page 2 (last mod. 8/19/84)