CUT(1) — USER COMMANDS
NAME
cut − remove selected fields from each line of a file
SYNOPSIS
cut −clist [ filename ... ]
cut −flist [ −dc ] [ −s ] [ filename ... ]
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 of fixed length, i.e., character positions as on a punched card, or of variable 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.
OPTIONS
−clist By character position. list is a comma-separated list of integer field numbers (in increasing order), with an optional − to indicate ranges:
1,4,7 characters 1, 4 and 7
1−3,8 characters 1 through 3, and 8
−5,10 characters (1) through 5, and 10
3− characters 3 through (last)
−flist By field position. Instead of character positions, list specifies fields that are separated a delimiter (normally a TAB):
1,4,7 fields 1, 4 and 7
Lines with no field delimiters are normally passed through intact (to allow for subheadings).
−dc Set the field delimiter to c. The default is a TAB. SPACE, or a character with special meaning to the shell must be quoted.
−s Suppress lines with no delimiter characters.
EXAMPLES
cut −d: −f1,5 /etc/passwd
mapping of user IDs to names
name=who am i | cut −f1 −d" "
to set name to the current login name.
DIAGNOSTICS
line too long A line can have no more than 1023 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
Sun Release 3.5 — Last change: 28 March 1986