cut command (Linux / bash / sh / zsh)
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 / option | Meaning |
|---|---|
| -d DELIM | Set the field delimiter. |
| -f LIST | Select delimited fields. |
| -c LIST | Select character positions. |
| --complement | Select 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.
Related commands
- awkProcess record-oriented text with patterns, fields, and actions.
- trTranslate, squeeze, or delete characters in a byte stream.
- sortOrder text lines using lexical, numeric, or keyed comparisons.
- grepSearch text for lines matching a pattern.
- Where-ObjectFilter pipeline objects by property values or a script block predicate.
- catConcatenate files and write their contents to standard output.
- Get-ContentRead file content or provider data as a stream of objects.
- echoWrite arguments and shell-expanded values to standard output.
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.