shell · difficulty ◆
cut — extract columns from text
Pull exactly the column you want out of any delimited or fixed-width text.
$ cutWhat it does
cut extracts selected portions of each input line. You can slice by delimiter-separated fields (-d and -f), by character positions (-c), or by byte ranges (-b). It reads from files or stdin, so it slots into pipes wherever you need to pull one column out of a table, a log line, or a CSV.
Why it matters
Logs, /etc/passwd, CSV exports, and command output are full of structured lines. cut is the fastest way to grab just the field you care about without loading a full parser. Paired with sort, uniq, and wc, it turns raw text into answers: 'which users are on this box?' or 'what are the top response codes?'
Example
$ cut -d: -f1 /etc/passwd$ cut -d: -f1 /etc/passwd
root
daemon
bin
sys
kmail
www-data-d: sets the delimiter to colon, -f1 takes the first field — the usernames.
$ echo '2026-08-27 09:10:42' | cut -c1-102026-08-27-c1-10 takes characters 1 through 10, pulling just the date out of a timestamp.
Common flags
- -d
- set the field delimiter (default is TAB)
- -f
- select fields by number, e.g. -f1,3 or -f2-4
- -c
- select characters by position, e.g. -c1-10
- -b
- select bytes by position (differs from -c for multibyte text)
- -s
- suppress lines that do not contain the delimiter
- --complement
- invert — output everything except the selected fields
- --output-delimiter
- change the delimiter used in the output
History
Origin
cut has been part of Unix since the 1980s, appearing in System III and System V. It was designed for the classic Unix job of slicing fixed-width and delimited records, and it has stayed essentially unchanged because the problem it solves — pulling a column out of text — is timeless.
Fun fact
cut is a pure filter: it never modifies the input file, only prints a transformed copy to stdout. That makes it safe to use in pipelines and scripts, and it is why cut, sort, uniq, and wc are so often chained together in a single line.