Linux command
cut 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Extract
cut -f [1,3] [file.txt]
Extract
cut -c [1-10] [file.txt]
Custom
cut -d [:] -f [1,7] [/etc/passwd]
Extract
cut -b [1-5] [file.txt]
说明
cut removes sections from each line of files. It extracts columns by character position, byte position, or field delimiter, making it useful for processing structured text data. The command is commonly used in shell scripts for parsing columnar data.
参数
- -f, --fields _list_
- Select fields (delimiter-separated)
- -c, --characters _list_
- Select characters
- -b, --bytes _list_
- Select bytes
- -d, --delimiter _char_
- Field delimiter (default: TAB)
- --output-delimiter _string_
- Output delimiter
- -s, --only-delimited
- Don't print lines without delimiter
- --complement
- Complement the selection
FAQ
What is the cut command used for?
cut removes sections from each line of files. It extracts columns by character position, byte position, or field delimiter, making it useful for processing structured text data. The command is commonly used in shell scripts for parsing columnar data.
How do I run a basic cut example?
Run `cut -f [1,3] [file.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f, --fields _list_ do in cut?
Select fields (delimiter-separated)