Can anyone point me at a 'pick' filter script that works somewhat as described below?
I've spent about an hour hunting for a simple bash script/filter that will allow me to pipe in a list of values and will spit out a subset of them depending on choices I make at the console. I know there are examples written in C but I wanted a mostly-portable bash script I can use in Cygwin / Gitbash etc. (The context: I want to be able to run some command in some subdirectories, and I want to separate the choice of which directories to run the command, from the choice of command to run.)
As hypothetical example of usage:
$ echo "foo
> bar
> baz" | pick.sh
* Options:
* 1. foo
* 2. bar
* 3. baz
* Choices? 2 3
bar
baz
The lines marked * are supposed to be where the script interactively lets me choose which elements to 'pick' and once I decided lines 2 and 3 it proceeds to send those out to STDOUT.
Choices ideally could be a combination of space-separated numbers eg 2 3 4, inclusive ranges eg 2-4 .. or maybe even fancy enough to use some kind of autocompletion allowing typing the first few letters of the items themselves.
Well, there it is, I think it would be a very useful bash pipeline filter in general!
(Thanks for reading this far..)
vipe
. – Kamil Maciorowski Jun 05 '20 at 22:56