choose
A human-friendly and fast alternative to cut and awk for selecting fields from command output.
choose is a simple, expressive alternative to cut and basic awk
field-selection one-liners. It uses an intuitive syntax for selecting fields and
ranges from lines of text, and is fast enough to handle large streams without
breaking a sweat.
Features
- Intuitive field selection — select fields by index using familiar Python-like range syntax
- Negative indexing — count fields from the end with negative indices
- Custom delimiters — split on any regex pattern, not just whitespace or a single character
- Output delimiter control — join selected fields with any separator you choose
- Rust-speed — processes large inputs significantly faster than equivalent
awkscripts
Installation
cargo install choose
Or via your package manager:
# macOS
brew install choose-rust
# Arch Linux
yay -S choose
# Debian / Fedora
# Pre-built Linux binaries are available on the
# [releases page](https://github.com/theryangeary/choose/releases).Usage
# Select the first field (0-indexed) from each line
echo "one two three" | choose 0
# → one
# Select the third field
echo "one two three" | choose 2
# → three
# Select a range of fields (inclusive)
echo "one two three four" | choose 1:3
# → two three four
# Select from field 1 to the end
echo "one two three four" | choose 1:
# → two three four
# Select the last field using negative indexing
echo "one two three four" | choose -1
# → four
# Use a custom delimiter (split on commas)
echo "a,b,c,d" | choose -f ',' 2
# → c
# Use a custom output delimiter
echo "one two three" | choose -o ',' 0:2
# → one,two,three
# Practical example: get the second column of ps output
ps aux | choose 1Comparison with cut
# cut requires 1-based indexing and a specific delimiter flag
cut -d' ' -f2 file.txt
# choose is more natural
choose 1 < file.txt
choose really shines in interactive shell sessions where you just want to grab
a column quickly without remembering awk's arcane field syntax or cut's
1-based indexing.