cut¶
Cuts columns or character ranges out of each line.

Syntax¶
cut OPTION... [FILE]...
Options¶
| Option | Description |
|---|---|
-d CHAR, --delimiter=CHAR |
Column separator (default: tab) |
-f LIST, --fields=LIST |
Columns to keep: 1, 1,3, 2-4, 3- |
-c LIST, --characters=LIST |
Character positions to keep: 1-10, 5- |
--complement |
Keep everything except the selected columns |
--output-delimiter=TEXT |
Separator between columns in the output |
Examples¶
Show all user names:
cut -d: -f1 /etc/passwd | head -n 3
root
daemon
bin
Show user name and login shell:
cut -d: -f1,7 /etc/passwd | grep bash
root:/bin/bash
nox:/bin/bash
Take columns from a CSV file:
cut -d, -f2,3 users.csv
name,email
nox,nox@example.com
alice,alice@example.com
bob,bob@example.com
Show only the IP addresses of a log:
cut -d' ' -f1 /var/log/nginx/access.log | head -n 3
192.0.2.10
192.0.2.10
198.51.100.23
Cut out the time stamp by character position:
cut -c1-19 deploy.log
2026-10-26 10:40:01
2026-10-26 10:40:12
2026-10-26 10:40:15
Show only the paths from the output of du:
du -sh /srv/* | cut -f2
/srv/README
/srv/backup
/srv/logs
/srv/www
du separates its columns with a tab, which is the default separator of cut.
When do I need it?¶
- To get single columns from
/etc/passwd, CSV exports or the output of other commands - To extract IP addresses, status codes or time stamps from logs for further processing
- In scripts that need one value from a line
Several spaces in a row: use awk
cut -d' ' treats every single space as a separator. If columns are aligned with
several spaces, the counting gets mixed up. awk handles this correctly.
CSV files with commas in values
A value like "Smith, John" contains a comma, and cut -d, splits it in two. For
real CSV data with quotes, use a tool that understands CSV.