c

cut(1)

cut(1)

NAME

cut - cut out (extract) selected ®elds of each line of a ®le

SYNOPSIS

cut -clist [ ®le ... ]

cut -blist [-n] [ ®le ... ]

cut -flist [-dchar ] [-s] [ ®le ... ]

DESCRIPTION

cut cuts out (extracts) columns from a table or ®elds from each line in a ®le; in data base parlance, it implements the projection of a relation. Fields as speci®ed by list can be ®xed length (de®ned in terms of character or byte position in a line when using the -cor -boption), or the length can vary from line to line and be marked with a ®eld delimiter character such as the tab character (when using the -foption). cut can be used as a ®lter; if no ®les are given, the standard input is used.

When processing single-byte character sets, the -cand -boptions are equivalent and produce identical results. When processing multi-byte character sets, when the -band -noptions are used together, their combined behavior is very similar, but not identical to the -coption.

Options

Options are interpreted as follows:

 

 

list

A comma-separated list of integer byte (-b option),

character (-c option), or ®eld (-f

 

option) numbers, in increasing order, with optional

- to indicate ranges. For exam-

 

ple:

 

 

 

1,4,7 Positions 1, 4, and 7.

 

 

1-3,8Positions 1 through 3 and 8.

 

 

-5,10

Positions 1 through 5 and 10.

 

 

3-

Position 3 through last position.

 

-blist

Cut based on a list of bytes. Each selected byte is output unless the -noption is also

 

speci®ed.

 

 

-clist

Cut based on character positions speci®ed by list (-c1-72extracts the ®rst 72 char-

 

acters of each line).

 

-flist

Where list is a list of ®elds assumed to be separated in the ®le by a delimiter charac-

 

ter (see -d); for example, -f 1,7 copies the ®rst and seventh ®eld only. Lines with

 

no ®eld delimiters will be passed through intact (useful for table subheadings), unless

 

-sis speci®ed.

 

 

-dchar

The character following -dis the ®eld delimiter (-f option only). Default is tab.

 

Space or other characters with special meaning to the shell must be quoted. Adjacent

 

®eld delimiters delimit null ®elds. char may be an international code set character.

-n

Do not split characters. If the high end of a range within a list is not the last byte of a

 

character, that character is not included in the output. However, if the low end of a

 

range within a list is not the ®rst byte of a character, the entire character is included

 

in the output."

 

 

-s

Suppresses lines with no delimiter characters when using -foption. Unless -sis

 

speci®ed, lines with no delimiters appear in the output without alteration.

Hints

Use grep to extract text from a ®le based on text pattern recognition (using regular expressions). Use paste to merge ®les line-by-line in columnar format. To rearrange columns in a table in a different sequence, use cut and paste. See grep(1) and paste(1) for more information.

EXTERNAL INFLUENCES

Environment Variables

LC_CTYPE determines the interpretation of text as single and/or multi-byte characters.

If LC_CTYPE is not speci®ed in the environment or is set to the empty string, the value of LANG is used as a default for each unspeci®ed or empty variable. If LANG is not speci®ed or is set to the empty string, a

Section 1162

− 1 −

HP-UX Release 11i: December 2000