2025-03-14 21:59:59 -06:00
|
|
|
# cut
|
|
|
|
|
|
|
|
|
|
> Cut out fields from `stdin` or files.
|
|
|
|
|
> More information: <https://keith.github.io/xcode-man-pages/cut.1.html>.
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Print the fifth [c]haracter on each line:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`{{command}} | cut -c 5`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Print the fifth to tenth [c]haracter of each line of the specified file:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`cut -c 5-10 {{path/to/file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Split each line in a file by a delimiter into fields and print [f]ields two and six (default delimiter is `TAB`):
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`cut -f 2,6 {{path/to/file}}`
|
|
|
|
|
|
|
|
|
|
- Split each line by the specified [d]elimiter and print all from the second [f]ield onward:
|
|
|
|
|
|
|
|
|
|
`{{command}} | cut -d "{{delimiter}}" -f 2-`
|
|
|
|
|
|
|
|
|
|
- Use space as a [d]elimiter and print only the first 3 [f]ields:
|
|
|
|
|
|
|
|
|
|
`{{command}} | cut -d " " -f -3`
|