Linux Terminal Command: cut

The cut command is an essential tool in File Manipulation & Viewing. In this tutorial, we will explore what cut does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The cut command cuts out sections from each line of a file and prints the result to stdout.


Common Options & Syntax

cut [options] [arguments]

Here are the most common flags used with cut:


1. Interactive Example (Simple)

Here is how most people run the command:

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

What it does: Extracts usernames (first field) from the colon-delimited /etc/passwd file.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
cut -c 1-10,15-20 data.txt

What it does: Extracts the first 10 characters and characters 15-20 of each line in ‘data.txt’.


⚙️ Warning & Common Pitfalls

[!WARNING] cut does not support multi-character delimiters. If fields are separated by variable whitespace, use awk instead.


Here are some related posts on cli_tty1 you might want to check out: