Beginner Package: coreutils

cut

Extract columns or fields from each line of text.

Syntax

cut [options] [file...]

Description

cut is a lighter-weight alternative to awk when you only need to pull out fixed columns or a delimiter-separated field, without needing a full pattern-matching language.

Examples

cut -d: -f1 /etc/passwd
Extract the first colon-separated field (username) from each line
cut -c1-10 file.txt
Extract the first 10 characters of each line
cut -d, -f2,4 data.csv
Extract the 2nd and 4th comma-separated fields

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux