Remove sections from each line of files.
The cut command removes sections from each line of input and writes the result to standard output. It can select portions of a line by byte position, character position, or field (delimited columns).
The -f option selects fields separated by a delimiter (tab by default), and -d specifies a custom delimiter. The -c option selects by character position, and -b by byte position.
cut is widely used for extracting columns from CSV files, parsing structured text output, and processing delimited data in shell pipelines.
| Name | Description | Optional |
|---|---|---|
file |
One or more files to process. Reads from stdin if omitted. | Yes |
-f |
Select only these fields, separated by the delimiter. | Yes |
-d |
Use the specified character as the field delimiter instead of tab. | Yes |
-c |
Select only these character positions. | Yes |
-b |
Select only these byte positions. | Yes |
cut -d: -f1 /etc/passwd
cut -f2,4 data.tsv
echo 'hello world' | cut -c1-5