Text and processing

The cut command

Cuts columns or fields from each line. Ideal for separated listings.

Syntax

cut -d <sep> -f <campos>

Most useful options

-dSets the separator
-fSelects the fields
-cSelects by character position

Copy-ready examples

$ cut -d : -f 1 /etc/passwdThe system users
$ printf 'a,b,c\n' | cut -d , -f 2The second field
$ cut -d : -f 1,3 /etc/passwdTwo fields

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • The default separator is the tab, not the comma.

Related commands

FAQ

cut or awk?

cut is simple and fast for fixed columns; awk can compute and filter.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course