The cut command in Linux

cut extracts sections from each line of input: fields split by a delimiter (-d -f) or fixed character positions (-c). For simple, consistently delimited data it is faster to type than awk; the moment separators become variable whitespace, switch to awk.

How cut works

cut applies one fixed slicing rule to every line — fields split on a single literal character, or absolute character positions — and outputs the selected pieces. No regex, no state, no surprises: a pure per-line transformation, which is why it is fast and why it composes so cleanly in pipelines.

Its limits are the flip side of that purity. One literal delimiter character means variable whitespace defeats it (that is awk territory). Selected fields always emerge in original order — -f3,1 will not reorder. And quoted CSV, where a comma may be data, is beyond any line-slicing tool: the escaping rules require a real parser. Knowing precisely where cut ends is what lets you reach for it with confidence inside its territory.

Syntax

cut -d DELIM -f FIELDS [FILE]   |   cut -c RANGES [FILE]

Common options

OptionWhat it does
-d","Field delimiter (a single character).
-f 1,3Which fields to keep (lists and ranges: 1,3 or 2-4 or 3-).
-c 1-8Character positions instead of fields.
--complementKeep everything except the named fields.

How to use cut: examples

$ cut -d',' -f1,3 users.csv

Columns 1 and 3 of a comma-separated file.

$ cut -d':' -f1 /etc/passwd

User names from the system account file.

$ cut -c1-10 access.log

The first ten characters of each line — e.g. a fixed-width date.

$ echo 'a:b:c:d' | cut -d':' -f2-

Field 2 to the end.

$ history | cut -c8-

Strip the line numbers from your shell history output.

Real-world use cases for cut

Extracting fields from system files

All usernames: cut -d: -f1 /etc/passwd. All shells in use: cut -d: -f7 /etc/passwd | sort -u. Colon-separated system files are cut's home turf — single-character delimiter, fixed positions, zero surprises.

Trimming fixed-width logs

Log lines starting with a fixed 19-character timestamp: cut -c21- strips it for cleaner diffing, and cut -c1-10 keeps just the date for grouping with sort | uniq -c.

Pro tips and common mistakes

Frequently asked questions about cut

Why does cut print the whole line unchanged?

The delimiter was not found on that line. cut passes such lines through untouched by default; add -s to suppress them.

Can cut use a multi-character delimiter?

No — -d takes exactly one character. For multi-character separators or variable whitespace, use awk -F or sed.

How do I cut on spaces when columns are aligned?

Aligned columns usually mean variable numbers of spaces, which cut can't handle. Use awk '{print $2}' — awk collapses whitespace automatically.

Related commands

sed

Stream-edit text: substitute, delete lines, and edit files in place with -i.

awk

Pull columns out of any output, filter rows, and compute sums — the shell's spreadsheet.

Want to build real fluency? The interactive course takes you through cut and every other essential command with guided, checked exercises.