2025-03-14 21:59:59 -06:00
|
|
|
# cut
|
|
|
|
|
|
|
|
|
|
> Cut out fields from `stdin` or files.
|
|
|
|
|
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/cut-invocation.html>.
|
|
|
|
|
|
|
|
|
|
- Print a specific [c]haracter/[f]ield range of each line:
|
|
|
|
|
|
|
|
|
|
`{{command}} | cut --{{characters|fields}} {{1|1,10|1-10|1-|-10}}`
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
- Print a field range of each line with a specific delimiter:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`{{command}} | cut {{[-d|--delimiter]}} "{{delimiter}}" {{[-f|--fields]}} {{1|1,10|1-10|1-|-10}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
- Print a character range of each line of the specific file:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`cut {{[-c|--characters]}} {{1}} {{path/to/file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
- Print specific fields of `NUL` terminated lines (e.g. as in `find . -print0`) instead of newlines:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`{{command}} | cut {{[-z|--zero-terminated]}} {{[-f|--fields]}} {{1}}`
|