Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

grep(1V)

paste(1V)

CUT(1V)  —  USER COMMANDS

NAME

cut − remove selected fields from each line of a file

SYNOPSIS

cut −clist [ filename ... ]

cut −flist [ −dc ] [ −s ] [ filename ... ]

AVAILABILITY

This command is available with the System V software installation option.  Refer to Installing SunOS 4.1 for information on how to install optional software. 

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, (such as on a punched card), or of variable length between lines.  They can be marked with a field delimiter character, such as TAB (as specified with the −d option).  cut can be used as a filter; if no files are given, the standard input is used.  In addition, a file name of ‘−’ explicitly refers to the standard input. 

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.  Characters with special meaning to the shell such as a TAB or SPACE characters, 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" "
Set name to the current login name. 

SEE ALSO

grep(1V), paste(1V)

DIAGNOSTICS

ERROR:  line too long
A line can have no more than 1023 characters or fields.

ERROR:  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. 

ERROR:  no fields
The list is empty. 

ERROR:  no delimiter
Missing char on −d option. 

ERROR:  cannot handle multiple adjacent backspaces
Adjacent backspaces cannot be processed correctly.

WARNING:  cannot open filename: reason
Either filename cannot be read or does not exist.  If multiple filenames are present, processing continues. 

WARNING:  I/O error reading filename: reason
An I/O error occurred when reading filename. If multiple filenames are present, processing continues.

Sun Release 4.1  —  Last change: 16 September 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026