cut - Extract Columns the Simple Way

Learn cut for extracting columns from text. Simpler than awk for basic field extraction.

commandsLast updated 2026-02-24

cut: awk's Simpler Little Sibling

You need column 2 from a file. You could use awk. Or you could use cut, which does one thing and does it well:

cut -d' ' -f2 file.txt

Second column, space-delimited. Done.

When to Use cut vs awk

  • Just extracting columns? Use cut. It's simpler.
  • Need filtering, math, or logic? Use awk.

cut is the tool when you know exactly which field you want and just want it fast.

The Basic Pattern

cut -d'DELIMITER' -f FIELD file.txt

-d sets what separates fields. -f picks which field(s) you want.

Common Delimiters

Space-separated:

cut -d' ' -f1 file.txt

Comma-separated (CSV):

cut -d',' -f2 data.csv

Colon-separated (like /etc/passwd):

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

Tab-separated (the default, actually):

cut -f1 file.tsv

Selecting Multiple Fields

Specific fields:

cut -d',' -f1,3 data.csv

Fields 1 and 3.

Range of fields:

cut -d' ' -f1-3 file.txt

Fields 1 through 3.

From field N to end:

cut -d' ' -f3- file.txt

Field 3 and everything after.

Cutting by Character Position

Sometimes you want character positions, not fields:

cut -c1-10 file.txt

First 10 characters of each line.

cut -c5 file.txt

Just the 5th character.

Real Examples

Get usernames from /etc/passwd:

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

Get the third column of a CSV:

cut -d',' -f3 sales.csv

Extract a fixed-width field:

cut -c1-8 log.txt

Quick Reference

| What you want | Command | |---------------|---------| | Field by delimiter | cut -d',' -f2 file | | Multiple fields | cut -d' ' -f1,3 file | | Field range | cut -d' ' -f2-4 file | | Character positions | cut -c1-10 file | | Tab-delimited | cut -f2 file |

Practice

cut is handy in CTF challenges for quick column extraction when you don't need awk's full power.


cut does one thing: extract fields. If that's all you need, it's faster to type than awk.