Skip to main content

Command referencecut

cut command (Linux / bash / sh / zsh)

Linuxbashshzshtextbeginner

What it does

Extract selected fields, characters, or bytes from each input line. When people search for the cut command linux columns, they usually want cut's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Extract selected fields, characters, or bytes from each input line.

Syntax

cut OPTION... [FILE]...

Common options

Flag / optionMeaning
-d DELIMSet the field delimiter.
-f LISTSelect delimited fields.
-c LISTSelect character positions.
--complementSelect everything except the listed range.

Practical examples

User names

cut -d: -f1 /etc/passwd

Extracts the first colon-delimited field.

CSV columns

cut -d, -f1,3 data.csv

Prints columns one and three for simple CSV.

First characters

cut -c1-8 codes.txt

Prints positions one through eight.

Common mistakes

  • Using cut for quoted CSV where delimiters can appear inside fields.
  • Forgetting field numbering starts at one.

FAQ

What does cut do in Linux?

Extract selected fields, characters, or bytes from each input line.

How do I use cut from the terminal?

Start with `cut OPTION... [FILE]...`, then choose only the options needed for the task.

What is a practical cut example?

Try `cut -d: -f1 /etc/passwd` — Extracts the first colon-delimited field.

Can I use cut in a shell script?

Yes. cut works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.