Fundamentals 2 min read

How to Use the cut Command to Extract Text Columns in Linux

This guide explains how to use the Unix cut command to extract specific columns or character ranges from files or streams, detailing the -d, -f, and -c options with clear examples such as selecting fields from colon‑separated data.

ZhiKe AI
ZhiKe AI
ZhiKe AI
How to Use the cut Command to Extract Text Columns in Linux

cut

Overview

Extract text columns from a file or stream.

Syntax

cut -d'delimiter' -f fields  # for specific delimiter
cut -c column_range          # for fixed-width aligned data

Options and parameters:

-d: specify delimiter, used with -f.

-f: select fields based on delimiter defined by -d.

-c: select character positions.

Examples

Create a file 1.txt with the following content: zhangsi:28:football:basketball:music:sing Extract the third field (football) using colon as delimiter: cut -d ':' -f 3 1.txt Extract the third and fifth fields (football and music): cut -d ':' -f 3,5 1.txt Extract from the third field to the end: cut -d ':' -f 3- 1.txt Extract fields three through five: cut -d ':' -f 3-5 1.txt Extract fields three through five and also the seventh field: cut -d ':' -f 3-5,7 1.txt Character‑based extraction example:

who | cut -c 3
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Shellcommand-lineUnixtext processingcut
ZhiKe AI
Written by

ZhiKe AI

We dissect AI-era technologies, tools, and trends with a hardcore perspective. Focused on large models, agents, MCP, function calling, and hands‑on AI development. No fluff, no hype—only actionable insights, source code, and practical ideas. Get a daily dose of intelligence to simplify tech and make efficiency tangible.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.