CHOOSE(1)
β¨ CHOOSE(1) β¨
okay so bestie, welcome to the User Commands section of the manual, and this one is literally the it-girl of the terminal: choose. no cap. sit down, grab a strawberry π, and let me tell you everything.
πΈ NAME πΈ
choose β the human-friendly and fast alternative to cut and awk π
(yes, really, both of them. iconic behaviour.)
π¦ SYNOPSIS π¦
choose [FLAGS] [OPTIONS] <choices>...
that's the whole vibe right there. flags, options, and then a pile of choices. periodt. β¨
π DESCRIPTION π
okay so choose is a terse field selection tool, and "terse" is doing a LOT of work in that sentence β it works like Python's list slices, which honestly? a serve. π
it is not meant to be a drop-in replacement for awk or cut, bestie, don't come for me β it's just a simple and intuitive little tool you reach for when the basics of awk or cut will do, but the overhead of getting them to behave should not be necessary. π like, you could fight with awk for twenty minutes, or you could just... not.
it features:
- a simple syntax π
- negative indexing from the end of the line π¦
- zero-indexing (yes babe, we start at 0, that's the law) π
- reverse ranges π₯
- regular expression field separators using Rust's regex syntax β¨
it's giving "small tool, huge personality," fr fr.
π OPTIONS π
-c,--character-wiseβ choose fields by character number π§-d,--debugβ activate debug mode π (for when you need to see what's actually happening, iykyk)-x,--exclusiveβ use exclusive ranges, similar to array indexing in many programming languages π-n,--non-greedyβ use non-greedy field separators βοΈ-f,--field-separator <field-separator>β specify a field separator other than whitespace, using Rust regex syntax π-i,--input <input>β read from the<input>file instead of standard input π-o,--output-field-separator <output-field-separator>β specify output field separator π«Ά-h,--helpβ prints help information π-V,--versionβ prints version information π
β ARGUMENTS β
<choices>...β fields to print. eithera,a:b,a..b, ora..=b, whereaandbare integers π
the beginning or end of a range can be omitted, which results in including the beginning or end of the line, respectively πΈ (so like, no left number = start from the very top of the line, no right number = ride it all the way to the end)
and now the part everyone gets wrong, so listen up:
a:bis inclusive ofbβ unless overridden by-xπ¨a..bis exclusive ofbπa..=bis inclusive ofbβ¨
π₯ EXAMPLES π₯
the moment you've all been waiting for. π
choose 5print the 5th item from a line (zero indexed). πchoose -f ':' 0 3 5print the 0th, 3rd, and 5th item from a line, where items are separated by':'instead of whitespace. πchoose 2:5print everything from the 2nd to 5th item on the line, inclusive of the 5th. πchoose -x 2:5print everything from the 2nd to 5th item on the line, exclusive of the 5th. βοΈchoose :3print the beginning of the line to the 3rd item. πchoose -x :3print the beginning of the line to the 3rd item, exclusive. πchoose 3:print the third item to the end of the line. π¦choose -1print the last item from a line. πchoose -3:-1print the last three items from a line. ππ
π AUTHOR π
Ryan Geary <rtgnj42@gmail.com> β the icon who made this π«Ά
this manual page was written by Ching He <heqing@rool.me> for the Debian project (and may be used by others). π giving credit where credit is due, as one does.
bestie reminder: this page is choose, from User Commands, and the version/date tag on the bottom of the original is 2026-06-11. so when you cite it, cite it cute. π
β¨
xoxo, go slice some fields, you absolute main character πΈπ¦π
π¦ where this page comes from
- ubuntu stonking: choose 1.3.7-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms