Skip to content

Linux cut Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux cut Guide

Complete beginner-friendly guide to cut on Linux, covering Arch Linux, CachyOS, and other distributions including text extraction, field selection, and data processing.


Table of Contents

  1. Understanding cut
  2. cut Basics
  3. Field Selection
  4. Delimiter Options
  5. Troubleshooting

Understanding cut

What is cut?

cut extracts columns from text.

Uses:

  • Extract fields: Get specific columns
  • Text processing: Process structured data
  • Data extraction: Extract from files
  • CSV processing: Handle CSV files

Why it matters:

  • Data processing: Extract specific data
  • Text manipulation: Process text files
  • Scripting: Useful in scripts

cut Basics

Extract Columns

Basic usage:

# Extract columns
cut -c 1-10 file.txt

# Extract characters 1-10

Extract Fields

By delimiter:

# Extract field
cut -d',' -f1 file.csv

# -d: Delimiter
# -f: Field number

Field Selection

Single Field

One field:

# Extract first field
cut -d',' -f1 file.csv

# Extract second field
cut -d',' -f2 file.csv

Multiple Fields

Several fields:

# Extract multiple fields
cut -d',' -f1,3,5 file.csv

# Fields 1, 3, and 5

Field Range

Range of fields:

# Extract range
cut -d',' -f1-5 file.csv

# Fields 1 through 5

Delimiter Options

Common Delimiters

Different separators:

# Comma
cut -d',' -f1 file.csv

# Tab (default)
cut -f1 file.txt

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

# Space
cut -d' ' -f1 file.txt

Troubleshooting

cut Errors

Check format:

# Verify delimiter
head -1 file.csv

# Check field count
awk -F',' '{print NF}' file.csv

Summary

This guide covered cut usage, field extraction, and text processing for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally