Hacker News new | ask | show | jobs
by oefrha 2210 days ago
Hmm, so compared to cut this

1. saves -f because it doesn’t support cut’s -b and -c modes (edit: actually -c is supported, I just didn’t see it);

2. Uses -f instead of -d, making it rather confusing for cut users;

3. Uses : instead of - for range specifications;

4. Offers an exclusive indexing mode;

5. Misses a bunch of other cut features (assuming coreutils cut).

Not sure I see much appeal...

Edit: Another thing I missed: regex separator instead of just character list.

2 comments

> Not sure I see much appeal…

The appeal is the same as replacing grep with a fancier searcher:

1. it has good and sensible defaults (field mode, also I'd have to check but hopefully and unlike cut it doesn't print the entire line when it's unhappy with the selection you asked for, that's worse error handling than ed) (edit: confirmed, if you give `choose` nonsensical selection it doesn't print anything e.g. if you ask `cut` for columns 10-15 of data with 3 columns it's going to print the source as-is, choose is properly going to print a bunch of empty lines, that alone makes it better than cut)

2. It works better on actual data, which is generally whitespace-separated rather than tab-separated, meaning cut requires preprocessing before it'll do anything of use

Can you massage cut or the data to fit? Yes, in the same way you can massage grep or your data to fit. That you don't have to and the utility behaves sensibly by default is appealing. This exact thing is one I've been thinking about for some time now, I'm glad somebody else agreed and did the legwork.

To get the appeal, give a generalized cut version of:

    echo -e "foo   bar   baz" | choose -1 -2