2024-12-30 14:38:15 +01:00
|
|
|
# tuc
|
|
|
|
|
|
|
|
> Cut text (or bytes) where a delimiter matches, then keep the desired parts.
|
|
|
|
> A more user-friendly and powerful version of `cut` with sensible defaults.
|
|
|
|
> More information: <https://github.com/riquito/tuc>.
|
|
|
|
|
|
|
|
- Cut and rearrange fields:
|
|
|
|
|
2025-04-22 06:20:48 +03:00
|
|
|
`echo "foo bar baz" | tuc {{[-d|--delimiter]}} '{{ }}' {{[-f|--fields]}} {{3,2,1}}`
|
2024-12-30 14:38:15 +01:00
|
|
|
|
|
|
|
- Replace the delimiter `space` with an arrow:
|
|
|
|
|
2025-04-22 06:20:48 +03:00
|
|
|
`echo "foo bar baz" | tuc {{[-d|--delimiter]}} ' ' {{[-r|--replace-delimiter]}} ' ➡ '`
|
2024-12-30 14:38:15 +01:00
|
|
|
|
|
|
|
- Keep a range of fields:
|
|
|
|
|
2025-04-22 06:20:48 +03:00
|
|
|
`echo "foo bar baz" | tuc {{[-d|--delimiter]}} ' ' {{[-f|--fields]}} {{2:}}`
|
2024-12-30 14:38:15 +01:00
|
|
|
|
|
|
|
- Cut using regular expressions:
|
|
|
|
|
2025-04-22 06:20:48 +03:00
|
|
|
`echo "a,b, c" | tuc {{[-e|--regex]}} '{{[, ]+}}' {{[-f|--fields]}} {{1,3}}`
|
2024-12-30 14:38:15 +01:00
|
|
|
|
|
|
|
- Emit JSON output:
|
|
|
|
|
2025-04-22 06:20:48 +03:00
|
|
|
`echo "foo bar baz" | tuc {{[-d|--delimiter]}} '{{ }}' --json`
|