Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux cut command

Extract selected fields or character ranges from each input line.

GNU Coreutils

Syntax

Command form
cut OPTION... [FILE]...

Common options

6 options
OptionWhat it does
-b, --bytes=LISTSelect byte positions.
-c, --characters=LISTSelect character positions.
-d, --delimiter=DELIMUse DELIM as the field delimiter (default tab).
-f, --fields=LISTSelect fields; requires delimiter-separated input.
-s, --only-delimitedSkip lines without the delimiter.
--complementSelect the complement of the chosen bytes, characters or fields.

Usage examples

3 examples

Extract selected fields or character ranges from each input line.

cut -d, -f1,3 users.csv

Print the first colon-separated field from each line.

cut -d: -f1 /etc/passwd

Print characters 1 through 12 from each line.

cut -c1-12 names.txt

Notes

cut works with simple delimiters, not general CSV quoting. Byte and character positions may differ with multibyte encodings.