cut — 25 Examples with OutputsCompact, copy-paste-ready HTML file with commands and sample outputs. Use it as a quick reference or print it to PDF.
cat <<'EOF' > data.txt alice bob charlie dave erin frank EOF cut -f1 data.txt
alice dave
cat <<'EOF' > csv.txt alice,bob,charlie dave,erin,frank EOF cut -d',' -f1,3 csv.txt
alice,charlie dave,frank
cat <<'EOF' > example.txt one:two:three:four:five a:b:c:d:e EOF cut -d':' -f2-4 example.txt
two:three:four b:c:d
-f3-)cat <<'EOF' > fruits.txt apple|banana|cherry|date x|y|z EOF cut -d'|' -f3- fruits.txt
cherry|date z
-f-2)cat <<'EOF' > letters.txt 1-2-3-4 a-b-c-d-e EOF cut -d'-' -f-2 letters.txt
1-2 a-b
--complement to remove fields (remove field 2)cat <<'EOF' > people.txt first:middle:last john:fitzgerald:kennedy jane:anna:doe EOF cut -d':' --complement -f2 people.txt
first:last john:kennedy jane:doe
-s)cat <<'EOF' > mixed.txt foo,bar,baz no_delim_line a,b,c EOF cut -d',' -f2 -s mixed.txt
bar b
-c1-5)cat <<'EOF' > words.txt elephant cat lioness EOF cut -c1-5 words.txt
eleph cat lione
-b1-3)cat <<'EOF' > bytes.txt abcdef 123456 EOF cut -b1-3 bytes.txt
abc 123
rev + cutcat <<'EOF' > path.txt /home/user/docs/report.txt /var/log/syslog EOF rev path.txt | cut -d'/' -f1 | rev
report.txt syslog
--output-delimiter)cat <<'EOF' > data2.txt a,b,c d,e,f EOF cut -d',' -f1,3 --output-delimiter='|' data2.txt
a|c d|f
psps aux | head -n 3 | tr -s ' ' | cut -d' ' -f2
1 234 5678
cat <<'EOF' > files.txt archive.tar.gz photo.jpg README EOF rev files.txt | cut -d'.' -f1 | rev
gz jpg README
cat <<'EOF' > tabs.txt col1 col2 col3 1 2 3 x y z EOF cut -f2 tabs.txt
col2 2 y
/etc/passwdhead -n 5 /etc/passwd | cut -d':' -f1
root daemon bin sys sync
cat <<'EOF' > colors.csv red,blue,green blue,yellow,red green,red,blue EOF cut -d',' -f1 colors.csv | sort -u
green red
cat <<'EOF' > text.txt ABCDEFGHIJ 0123456789 EOF cut -c1-3,7-9 text.txt
ABCGHI 012678
cat <<'EOF' > report.txt ID Name Score 01 Alice 093 02 Bob 087 EOF cut -b1-3,5-14,16-18 report.txt
ID Name Score 01 Alice 093 02 Bob 087
cat <<'EOF' > sample.txt A:1:foo:bar B:2:baz:qux EOF cut -d':' --complement -f1 sample.txt
1:foo:bar 2:baz:qux
cat <<'EOF' > dataset.csv id,name,email 1,Alice,a@example.com 2,Bob,b@example.com EOF head -n1 dataset.csv | cut -d',' -f2
name
paste then cutcat <<'EOF' > a.txt apple banana cherry EOF cat <<'EOF' > b.txt red yellow red EOF paste a.txt b.txt | cut -f1
apple banana cherry
cat <<'EOF' > spaced.txt col1 col2 col3 one two three EOF tr -s ' ' < spaced.txt | cut -d' ' -f3
col3 three
cat <<'EOF' > weird.txt "Smith, John"|30|"New York, NY" "Doe, Jane"|25|"San Francisco, CA" EOF cut -d'|' -f1,3 weird.txt
"Smith, John"|"New York, NY" "Doe, Jane"|"San Francisco, CA"
seq + paste to create columnsseq 1 6 | paste - - - | cut -f2
2 5
grep + cutcat <<'EOF' > services.txt ssh:22:open http:80:open smtp:25:closed ftp:21:open EOF grep ':open$' services.txt | cut -d':' -f1,2
ssh:22 http:80 ftp:21