cut

selectively display fields or characters from input lines 

Command


SYNOPSIS

cut -b list [-n] [file...]

cut -c list[file...]

cut -f list [-d char] [-s] [file...]


DESCRIPTION

cut reads input from files and selectively copies sections of the input lines to the standard output. If you do not specify any files, or you specify a file named -, cut reads from the standard input.

Options

-b list 

invokes byte position mode. After this comes a list of the byte positions you want to display. This list may contain multiple byte positions, separated by commas (,) or blanks, or ranges of positions separated by dashes (-); since the list must be one argument, shell quoting is necessary if blanks are used. You may combine these to select any set of byte positions.

-c list 

invokes character position mode. After this comes a list of character positions to retain in the output. This list may contain multiple character positions, separated by commas (,) or blanks or ranges of positions separated by a single dash (-); since the list must be one argument, shell quoting is necessary if blanks are used. You may combine these to select any set of character positions.

-d char 

specifies char as the character that separates fields in the input data; by default, this is the horizontal tab.

-f list 

invokes field delimiter mode. After this comes a list of the fields you want to display. This list may contain multiple fields, separated by commas (,) or blanks or ranges of fields separated by a single dash (-); since the list must be one argument, shell quoting is necessary if blanks are used. You may combine these to select any set of fields.

-n 

does not split characters. If the low byte in a selected range is not the first byte of a character, cut extends the range downward to include the entire character; if the high byte in a selected range is not the last byte of a character, cut limits the range to include only the last entire character before the high byte selected. If -n is selected, cut does not list ranges that do not encompass an entire character and these ranges do not cause an error.

-s 

does not display lines that do not contain a field separator character. Normally, cut displays lines that do not contain a field separator character in their entirety.


EXAMPLES

This example takes the output from a ls -l command and displays only the permissions (that is, character positions 1-11) as well as the date, time, and file name information (that is, everything from the 56th character onward) for each file:

ls -l | cut -c 1-11,56-

DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— cannot open the input file
— out of memory
2 

Failure due to any of the following:

— an invalid command line argument
— you did not specify any of -b, -c or -f
— you omitted the list argument
— badly formed list argument


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. UNIX System V. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
paste, uname


PTC MKS Toolkit 10.1 patch 1 Documentation Build 2.