CUT(1) User Commands CUT(1)

cut - cut out selected fields of each line of a file

cut -b list [-n] [file . . . ]
cut -c list [file . . . ]
cut -f list [-d char] [-s] [file . . . ]

The cut utility selects columns of files for printing based either on byte position, character position, or field delimiters.

If no file is given, or if file is -, cut reads from standard input.

The list consists of numbers separated by commas or blanks that select the corresponding input field, starting at 1. Ranges of fields may be given as in

Selects all fields from m to n.
Selects all fields from m to the last field of each input line.
Selects all fields from the first field to n.

The cut command accepts the following options:

Each character of an input line forms a column. All selected characters are printed without intervening separators; all newline characters of the input file are passed through.
Sets the field delimiter character for the -f option to char.
Columns are sequences of zero or more characters separated by a field delimiter character, by default a tabulator (\t). The selected fields are printed, separated by the field delimiter character. Lines that do not contain the field delimiter character are passed through unchanged.
With the -f option, lines that do not contain the field delimiter character are not passed through.

The following options were introduced by POSIX.2:

Each single byte of an input line forms a column. All selected bytes are printed without intervening separators; all newline characters of the input file are passed through.
Changes the behavior of the -b option such that ranges start and end at character boundaries.

See locale(7).
Determines the mapping of bytes to characters for the argument to the -d option and in input files processed with the -bn, -c, and -f options.

paste(1), locale(7)

Since cut -f cannot be told to recognize both space and tabulator as delimiters, or to take adjacent delimiter characters as single delimiters, it is not generally usable to select fields of white-space separated tables. Use awk(1) for this purpose.

12/6/04 Heirloom Toolchest