cut
Quick Reference
Command Name:
cut
Category:
text processing
Platform:
linux
Basic Usage:
Common Use Cases
- 1
Text field extraction
Extract specific fields from text data
- 2
Data processing
Process structured data like CSV files
- 3
Log analysis
Extract specific information from log files
- 4
Script automation
Automate text processing in shell scripts
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:
cut -d: -f1 /etc/passwd
cut -d, -f1,3 data.csv
cut -c1-10 file.txt
cut -c1,3,5 file.txt