Skip to content
Latchkey

cut -f: Extract Columns by Field

cut -f pulls out the chosen fields from each line, split on a delimiter you set with -d.

cut is the fastest way to grab a column from tool output. The key detail is that its default delimiter is a tab, not a space.

What it does

cut -f selects fields, numbered from 1, split on the delimiter given by -d (default is a single TAB). You can pass a list and ranges, like -f1,3 or -f2-4. Each input line yields the selected fields joined by the same delimiter.

Common usage

Terminal
cut -d: -f1 /etc/passwd          # usernames
cut -d, -f2,4 data.csv            # 2nd and 4th CSV columns
cut -f1 data.tsv                  # default tab delimiter
ps aux | tr -s ' ' | cut -d' ' -f2   # PIDs (squeeze spaces first)

Options

FlagWhat it does
-f <list>Fields to keep, e.g. 1,3 or 2-4 or 3-
-d <char>Field delimiter (default TAB)
-sSuppress lines with no delimiter
--complementOutput all fields except the selected ones
--output-delimiter=<s>Join output fields with a different string

In CI

cut -d splits on a single literal character and does not collapse runs, so space-separated tool output (like ps aux) needs tr -s ' ' first to squeeze repeated spaces. For real columnar work, awk is often more robust than cut.

Common errors in CI

cut splits on one delimiter character only, so multiple spaces create empty fields and your -f numbers drift; squeeze with tr -s first. By default a line with no delimiter is printed whole; add -s to drop such lines. cut -d' ' cannot use a multi-character separator.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →