The cut command

remove sections from each line of files 8 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.

Options in the examples

-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified

Examples

cat /etc/passwd | cut -d: -f1 | sort | head -10
cut -d: -f1 /etc/passwd

Field 1, delimiter :

cut -d: -f1,3 /etc/passwd

Fields 1 and 3

cut -d, -f2 data.csv

CSV second column

cut -c1-10 file.txt

Characters 1-10

cut -c5- file.txt

From character 5 to end

cut -d: -f7 /etc/passwd | sort | uniq -c
cut -d, -f1 data.csv | tr 'a-z' 'A-Z'

Lessons that use cut

Related commands