text
cut
Extracts sections from each input line by byte, character, or delimited field. Handy for pulling columns out of CSV or colon-delimited files.
cut OPTION... [FILE]... Common flags
| Flag | Purpose |
|---|---|
| -d | Use DELIM as the field delimiter (single char) |
| -f | Select fields (e.g. 1,3 or 2-5) |
| -c | Select characters by position |
| -b | Select bytes by position |
| --complement | Output all fields except the selected ones |
| -s | Suppress lines that contain no delimiter |
Examples
cut -d: -f1 /etc/passwd Get the username column
cut -d, -f1,3 data.csv Keep columns 1 and 3 from a CSV
cut -c1-8 log.txt Show the first eight characters of each line
cut -d$'\t' -f2- data.tsv Drop the first tab-separated column
Gotcha
cut takes a single-character delimiter and cannot handle quoted CSV; use awk or a CSV-aware tool for real CSV data.
Related commands
awk
Pattern-action language for processing columnar text. Excellent for reshaping tabular data, aggregating fields, and quick reports.
sort
Sorts lines of text. Supports numeric, human-numeric, reverse, unique, and keyed sorting.
sed
Stream editor that applies a small program to each line of input. Widely used for search-and-replace and inline file edits.
cat
Concatenates files and prints them to standard output. Also useful as a simple viewer or to feed content into pipelines.
grep
Searches text for lines matching a regular expression. Central to log analysis and pipeline filtering.