Extract specific fields or character ranges from text.
low risk
cut extracts columns from text by delimiter (-d and -f) or character position (-c). A staple for parsing structured output like /etc/passwd, CSV files, or command output with consistent delimiters.
| Flag | Meaning |
|---|---|
-d --delimiter | Set field delimiter (default: TAB) |
-f --fields | Select specific fields (1-indexed) |
-c --characters | Select specific character positions |
cut -d: -f1 /etc/passwdExtract just usernames · explain & risk-check →cut -d, -f1,3 data.csvExtract first and third CSV columns · explain & risk-check →echo 'hello world' | cut -d' ' -f2Extract second word · explain & risk-check →cut -c1-10 longfile.txtShow only first 10 characters per line · explain & risk-check →For multi-character delimiters or more complex field logic, switch to `awk -F 'delim' '{print $2}'` — cut only supports single-character delimiters.
Reference text is hand-written and may be incomplete — check man cut for your version. Test destructive commands on a non-production system first.