LinuxCommandLibrary

choose

human-friendly alternative to cut and awk

TLDR

Select first field

$ echo "one two three" | choose 0
copy
Select third field
$ echo "a b c d e" | choose 2
copy
Select range of fields
$ echo "a b c d e" | choose 1:3
copy
Select from end (last field)
$ echo "a b c d e" | choose -1
copy
Select last three fields
$ echo "a b c d e" | choose -3:
copy
Custom field separator
$ echo "a,b,c" | choose -f ',' 1
copy
Regex field separator
$ echo "a1b2c" | choose -f '[0-9]' 0:
copy
Select exclusive range
$ echo "a b c d e" | choose 1:4 --exclusive
copy

SYNOPSIS

choose [options] field[:end]

DESCRIPTION

choose is a human-friendly, fast alternative to cut and awk for selecting fields from text input. It uses Python-like slice syntax with zero-based indexing, negative indices for counting from the end, and inclusive ranges by default.
Unlike cut, which requires exact delimiter specification and uses 1-based indexing, choose handles whitespace splitting automatically and supports regex-based field separators. Written in Rust, it is significantly faster than awk for simple field selection tasks.

PARAMETERS

-f, --field-separator sep

Field separator (regex supported)
-o, --output-field-separator sep
Output separator (default: space)
-x, --exclusive
Exclude end index from range
-c, --character-wise
Select characters instead of fields
-n, --non-greedy
Use non-greedy field splitting

FIELD SYNTAX

N

Single field (0-indexed)
N:M
Range from N to M (inclusive)
N:
From N to end
:M
From start to M
-N
Nth field from end

CAVEATS

Zero-indexed (first field is 0). Faster than cut for long inputs, much faster than awk. Install via cargo or brew install choose-rust.

SEE ALSO

cut(1), awk(1), sed(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community