Scroll to navigation

CUT(1) General Commands Manual CUT(1)

NAME

cut - Extract sections from each line of files.

SYNOPSIS

cut OPTION... [FILE]...

DESCRIPTION

Extract sections from each line of files.

OPTIONS

extract bytes listed in LIST
extract characters listed in LIST
use DELIM as field separator (default: Tab)
use any whitespace (Space/Tab) as delimiter; ignore leading and trailing blanks with 'trimmed'

Possible values:

trimmed
extract fields listed in LIST
like -f, but merge adjacent delimiters; the delimiter defaults to whitespace and the output delimiter to a space
invert selection: print all columns except the specified ones
suppress lines that do not contain the delimiter
use NULL (\0) instead of newline as line terminator
replace input delimiter with NEW_DELIM in output
with -b, do not output partial multi-byte characters
Print help
Print version

EXTRA

If no FILE is specified, reads from stdin. Use '-' as a FILE argument to include stdin.

LIST is a comma-separated list of numbers or ranges:


N only column N
N- columns N through the end of the line
N-M columns N through M
-M columns 1 through M

Examples:


cut -f 2,5-7 file.txt extract fields 2, 5, 6, and 7
cut -f 3- file.txt extract field 3 to the end of the line
cut --complement -f 4-6 file.txt extract all fields except 4, 5, and 6
cut -d',' -f1 file.csv extract first field from a CSV

VERSION

v(uutils coreutils) 0.12.0

EXAMPLES

Print the fifth character on each line:

command | cut [-c|--characters] 5

Print the fifth to tenth character of each line of the specified file:

cut [-c|--characters] 5-10 path/to/file

Split each line in a file by a delimiter into fields and print fields two and six (default delimiter is `TAB`):

cut [-f|--fields] 2,6 path/to/file

Split each line by the specified delimiter and print all from the second field onward:

command | cut [-d|--delimiter] "delimiter" [-f|--fields] 2-

Use space as a delimiter and print only the first 3 fields:

command | cut [-d|--delimiter] " " [-f|--fields] -3

Only print lines that contain the delimiter:

command | cut [-d|--delimiter] ":" [-f|--fields] 1 [-s|--only-delimited]

Print specific fields of lines that use `NUL` to terminate lines instead of newlines:

find . -print0 | cut [-z|--zero-terminated] [-d|--delimiter] "/" [-f|--fields] 2

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

2026-09-17