text

cut

Extracts sections from each input line by byte, character, or delimited field. Handy for pulling columns out of CSV or colon-delimited files.

cut OPTION... [FILE]...

Common flags

Flag Purpose
-d Use DELIM as the field delimiter (single char)
-f Select fields (e.g. 1,3 or 2-5)
-c Select characters by position
-b Select bytes by position
--complement Output all fields except the selected ones
-s Suppress lines that contain no delimiter

Examples

cut -d: -f1 /etc/passwd

Get the username column

cut -d, -f1,3 data.csv

Keep columns 1 and 3 from a CSV

cut -c1-8 log.txt

Show the first eight characters of each line

cut -d$'\t' -f2- data.tsv

Drop the first tab-separated column

Gotcha

cut takes a single-character delimiter and cannot handle quoted CSV; use awk or a CSV-aware tool for real CSV data.

Related commands

← All Linux commands · Linux cheat sheet