Quick take: The cut command extracts portions of each line. Use -d to set a delimiter and -f to pick fields (cut -d ',' -f1,3), or -c to cut by character position.

Introduction

The cut command pulls out specific columns from each line of text — by delimiter, character position, or byte. It is the simplest tool for slicing structured data like CSV files, /etc/passwd, or fixed-width output, and it is faster to type than awk for basic field extraction.

This guide covers cutting by delimiter and by character, selecting ranges of fields, and where cut fits compared with awk.

Syntax

The basic syntax of the cut command is:

cut [OPTIONS] [FILE...]

Common Options and Parameters

The most useful options and parameters for the cut command:

OptionDescription
-d DELIMSet the field delimiter (default is TAB).
-f LISTSelect fields (e.g. -f1,3 or -f2-4).
-c LISTSelect characters by position (e.g. -c1-10).
-b LISTSelect bytes by position.
--complementInvert the selection (keep everything else).
-sSuppress lines that do not contain the delimiter.

Practical Examples

Real cut commands you can run today:

# Get the first field of a CSV
cut -d ',' -f1 data.csv
# Get fields 1 and 3
cut -d ',' -f1,3 data.csv
# Get a range of fields
cut -d ',' -f2-4 data.csv
# Usernames from /etc/passwd
cut -d ':' -f1 /etc/passwd
# First 8 characters of each line
cut -c1-8 log.txt
# Everything except field 2
cut -d ',' --complement -f2 data.csv

Tips and Best Practices

  • cut splits on a single character delimiter — for data separated by multiple spaces, use awk instead, which treats runs of whitespace as one separator.
  • Combine cut with sort and uniq to summarise a column: cut -d ',' -f3 data.csv | sort | uniq -c.
  • Use -s to skip lines that have no delimiter, avoiding stray full lines in your output.

Final Thoughts

cut is the quickest way to extract columns from delimited or fixed-width text. Learn -d and -f for delimited data and -c for character positions, and reach for awk when fields are separated by variable whitespace or you need calculations. For everyday CSV and config slicing, cut is hard to beat.

FAQ: cut Command in Linux

How do I extract a column with cut?+

Set the delimiter with -d and the field with -f: cut -d ',' -f2 data.csv prints the second comma-separated column. Use -f1,3 for several fields or -f2-4 for a range.

How do I cut by character position?+

Use -c with a range: cut -c1-10 file prints the first 10 characters of each line. This is useful for fixed-width data.

Why does cut not work with space-separated data?+

cut splits on a single delimiter character, so multiple spaces create empty fields. For whitespace-separated columns, use awk '{print $2}', which collapses runs of spaces.

How do I get usernames from /etc/passwd?+

Use the colon delimiter: cut -d ':' -f1 /etc/passwd lists every username, since the first field of each line is the user name.

How do I select everything except one column?+

Use --complement: cut -d ',' --complement -f2 data.csv keeps every field except the second.

Need help with Linux servers or infrastructure?

Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.

Hire Me for Support