cut command
Cut out columns or characters from each line.
- Text processing
- Package coreutils
- 5 options · 5 examples
Syntax
cut [options] [file…]Provided by the coreutils package. Run man cut for the full manual.
Common options
| Option | What it does |
|---|---|
-d SEP | Field delimiter (default tab) |
-f LIST | Fields to keep, e.g. 1,3 or 2-4 |
-c LIST | Characters to keep |
--complement | Keep everything except the selected fields |
--output-delimiter=STR | Delimiter in the output |
Examples
Usernames from /etc/passwd
cut -d: -f1 /etc/passwdColumns 1 and 3 of a CSV
cut -d, -f1,3 data.csvFirst 8 characters of each line
cut -c1-8 file.txtEverything except column 2
cut -d, -f2 --complement data.csvHostname part of a FQDN
echo "web1.example.com" | cut -d. -f1
No example matches. Check the options table or search the guides.
Tips
cutcan't handle runs of spaces; useawkfor space-separated output.
cut guides
- Cut Command in Linux with Examples Linux Commands · Updated Apr 2025
