cut
Quick Reference
Command Name:
cut
Category:
text processing
Platform:
linux
Basic Usage:
Common Use Cases
Syntax
cut OPTION... [FILE]...
Options
Option | Description |
---|---|
-b, --bytes=LIST | Select only the bytes in positions listed in LIST |
-c, --characters=LIST | Select only the characters in positions listed in LIST |
-d, --delimiter=DELIM | Use DELIM as the field delimiter character instead of TAB |
-f, --fields=LIST | Select only the fields listed in LIST, also print any line that contains no delimiter character, unless the -s option is specified |
-n | (ignored) |
--complement | Complement the set of selected bytes, characters, or fields |
-s, --only-delimited | Do not print lines not containing delimiters |
--output-delimiter=STRING | Use STRING as the output delimiter, the default is to use the input delimiter |
-z, --zero-terminated | Line delimiter is NUL, not newline |
--help | Display help message and exit |
--version | Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the cut
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Extract characters 1-5 from each line cut -c 1-5 filename.txt
Advanced Examples:
# Combine cut with other commandscat /etc/passwd | cut -d ':' -f 1,7 | sort