UnixDroid

Text · Linux command

cut command in Linux

What does cut do?

cut takes columns out of each line, split by a delimiter (-d) and choosing fields (-f).

cut -d DELIM -f FIELDS [file]

Most useful options

OptionWhat it does
-ddelimiter, e.g. -d: or -d,
-ffields, e.g. -f1 or -f1,3
-ccharacters, e.g. -c1-8

cut examples

$ cut -d: -f1 /etc/group Try it ›

every group name

$ cut -d, -f2 data.csv Try it ›

column 2 of a CSV

$ cut -c1-10 file Try it ›

first 10 characters

In security work

cut -d, -f2 data.csv pulls one column out of a CSV export in a second.

Questions about cut

What is the difference between cut and awk?

cut is simple and fast with one fixed delimiter; awk handles spaces of any width and can do logic.