← All commands
THE COMMAND REFERENCE

cut

Select columns or character ranges from each line.

Last updated

BusyBox

Implementation-level reference; examples are not certified for every installed version.

Overview

cut prints chosen parts of every input line: fields split by a delimiter, or character positions. It is the simple way to pull a column out of delimited text.

Background

The manuals disagree about where cut came from: the macOS manual says it appeared in System III Unix, while the FreeBSD manual says it first appeared in 4.3BSD-Reno, so treat its origin as uncertain. Today the name covers GNU cut, the cut that macOS ships, and the cut applet in BusyBox. They agree on -d, -f, and -c with ranges, and differ on long options such as --complement.

Examples

Print the first comma-separated field:

cut -d, -f1 data.csv

Print the second field:

cut -d, -f2 data.csv

Print fields 1 and 2:

cut -d, -f1,2 data.csv

Print field 2 through the end of the line:

cut -d, -f2- data.csv

Print the first three characters of each line:

cut -c1-3 notes.txt

Split text from a pipeline on spaces; quote the space delimiter:

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

Options

-d
Set the field delimiter to this single character. The default is a tab.

-f
Select fields by number: 1, 1,3, 2-, or -2. Lines without the delimiter are printed whole unless you
suppress them.

-c
Select character positions, for example 1-3. In some locales a character is more than one byte.

Common mistakes

cut has no notion of quoted fields, so a comma inside quotes in CSV still splits the line. It cannot reorder fields: -f2,1 prints them in file order. Runs of spaces are separate delimiters, so use awk for whitespace-aligned columns.

Portability

-d, -f, and -c with the ranges above are in the Common examples. The Common examples were executed on GNU coreutils 9.11, macOS system tools, and BusyBox 1.37.0 (see the development guide for the exact check).

About BusyBox cut

BusyBox bundles cut as an applet, and anything beyond the common options depends on how it was built. This page's examples ran on BusyBox 1.37.0.

BusyBox notes

BusyBox cut supports -d, -f, and -c; other options depend on the build.

References

Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.