Linux command list

cut command: keep only the columns you need

__ __ _ _____
\ \ / /__| |_|_ _|__ _ __ _ __ ___
\ \ /\ / / _ \ '_ \| |/ _ \ '__| '_ ` _ \
\ V V / __/ |_) | | __/ | | | | | |
\_/\_/ \___|_.__/|_|\___|_| |_| |_| |_
 
A sandbox for trying cut. Nothing here can touch your real files.
user@webterm:~/project$
 

cut takes selected fields or characters out of every line. Learn when to use `-d` with `-f` and when to cut by character position with `-c`, by running the commands in a real terminal in your browser.

Updated: 2026-09-06

Syntax

cut -d separator -f fields file
cut -c positions file

It keeps the part of each line you asked for.

Try it first

Pull the name column out of a CSV.

$ cat users.csv
id,name,team,email
1,ada,web,ada@example.com
2,linus,infra,linus@example.com
3,grace,infra,grace@example.com
$ cut -d, -f2 users.csv
name
ada
linus
grace

-d is the separator and -f is which field. List several with commas.

$ cut -d, -f1,3 users.csv
id,team
1,web
2,infra
3,infra

2- means from there to the end.

$ cut -d, -f2- users.csv
name,team,email
ada,web,ada@example.com
linus,infra,linus@example.com
grace,infra,grace@example.com

Cutting by position

When the columns line up, use -c. If the first ten characters are the date:

$ cat logs/access.log
2026-09-06 10:12:33 200 /index
2026-09-06 10:12:41 404 /missing
2026-09-06 10:13:02 200 /index
2026-09-07 09:01:15 500 /boom
2026-09-07 09:02:44 200 /index
$ cut -c1-10 logs/access.log
2026-09-06
2026-09-06
2026-09-06
2026-09-07
2026-09-07

-c ignores separators entirely and counts characters.

Cutting before counting

cut usually appears just before a count. Take the status column and tally it.

$ cut -d' ' -f3 logs/access.log
200
404
200
500
200
$ cut -d' ' -f3 logs/access.log | sort | uniq -c
      3 200
      1 404
      1 500

When the separator is a tab

Leave out -d and the separator is a tab.

$ cut -f2 report.tsv
status
200
404

For colon-separated files, -d:. Names and login shells out of /etc/passwd is the example you will meet most often.

$ cut -d: -f1,7 /etc/passwd
root:/bin/bash
user:/bin/zsh
deploy:/bin/bash

When you actually reach for it

cut is what you type to narrow a line down before passing it on.

SituationWhat to type
Read one column of a CSVcut -d, -f2 users.csv
Take the date off a log linecut -c1-10 access.log
Count status codescut -d' ' -f3 access.log | sort | uniq -c
List the user names on a machinecut -d: -f1 /etc/passwd
Read a column of a TSVcut -f2 report.tsv

Things that trip people up

Fields cannot be reordered. cut -d, -f3,1 still prints 1 before 3. Reordering, calculating, or filtering by a condition are all awk territory.

-c and -f are mutually exclusive.

$ cut -c1 -f1 users.csv
cut: only one type of list may be specified

-d only means something with -f.

$ cut -c1-4 -d, users.csv
cut: an input delimiter may be specified only when operating on fields

One of them is required.

$ cut users.csv
cut: you must specify a list of bytes, characters, or fields

Practise it hands-on

webterm.appthis site

learn.webterm.appa separate site

>_WEBTERM LEARN

WebTerm Learn: from one command to actually using it

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.

See the course

Related commands

awk / sort / uniq / grep

Frequently asked questions

What is the difference between -f and -c?
`-f` counts fields, `-c` counts characters. Use `-f` for data separated by commas or colons, and `-c` when the columns line up, such as the date at the start of a log line.
What happens if I leave out -d?
The separator is a tab. TSV files work with plain `cut -f2`, while CSV needs `-d,`.
What about lines without the separator?
They come through whole, uncut. Filtering with `grep` first keeps the output readable.
Can I reorder the columns?
No. `cut -f3,1` still prints field 1 before field 3. Reordering is a job for `awk`.
It cuts space-separated logs badly.
Two spaces in a row create an empty field. Use `-c` if the columns line up, and `awk` if they do not.