`select` is a `bash` builtin to create menus for (console-only) user interaction. For GUI-based interaction, see `dialog` (note: non-standard in various distros).
Questions tagged [select]
34 questions
12
votes
4 answers
bash: whitespace-safe procedural use of find into select
Given these file names:
$ ls -1
file
file name
otherfile
bash itself does perfectly fine with embedded whitespace:
$ for file in *; do echo "$file"; done
file
file name
otherfile
$ select file in *; do echo "$file"; done
1) file
2) file name
3)…
DopeGhoti
- 73,792
- 8
- 97
- 133
12
votes
2 answers
Using `select` command to print a menu in Bash
I am trying to implement a simple menu using the select command. The script (for testing purposes) is as follows:
#!/bin/bash
echo "*******************"
PS3='Select an option and press Enter: '
options=("apache" "named" "sendmail")
select opt in…
Sumod
- 597
- 2
- 6
- 9
11
votes
2 answers
Can I change how select options are displayed?
I'm working with select and case in bash. I currently have nine options, which makes a nice, tidy, 3x3 grid of options, but it displays like so:
1) show all elements 4) write to file 7) clear elements
2) add elements 5) generate…
RICK
- 369
- 1
- 3
- 10
9
votes
5 answers
bash - How can I re-display selection menu after a selection is chosen and performed
I am making a tool script for my theme with 2 functions: Check for update, reinstall theme
So here is the code for selection menu:
PS3='Choose an option: '
options=("Check for update" "Reinstall theme")
select opt in "${options[@]}"
do
case…
superquanganh
- 3,721
- 5
- 14
- 14
3
votes
4 answers
How do I select an array to loop through from an array of arrays?
#!/usr/bin/bash
ARGENT=("Nous devons économiser de l'argent."
"Je dois économiser de l'argent.")
BIENETRE=("Comment vas-tu?" "Tout va bien ?")
aoarrs=("${ARGENT}" "${BIENETRE}")
select arr in "${aoarrs[@]}"; do
for el in "${arr[@]}"; do
…
John Smith
- 561
- 2
- 14
3
votes
2 answers
Bash ignoring SIGINT trap when 'select' loop is running
When i use 'trap' combined with select loop, namely when i try to hit CTRL+C to break out while options are displayed, it will just print ^C in terminal. If i remove 'trap' from script it will normally exit out, that is it will accept CTRL+C.
I've…
Marko Todoric
- 357
- 2
- 17
3
votes
2 answers
Creating Menu list and Executing the Task
I was given the the Task to create a menu in Linux but it appears it's not coming out great. When I select something I want to be able to perform that task then go back to the main menu when I finish.
#!/bin/bash
PS3='What do you want to do day:…
Krup
- 45
- 1
- 5
2
votes
2 answers
select from a constructed list of strings with whitespace?
I trying to create a list of strings with spaces in, that I want to choose between in a select - something like this:
sel=""
while read l
do
sel=$(printf "%s '%s'" "$sel" "$l")
done< <(cd /some/data/directory;du -sh *)
select x in $sel
do
…
j4nd3r53n
- 579
- 2
- 11
2
votes
2 answers
select would indicate pipe is readable when there's no data in pipe and write end is closed?
I am reading The Linux Programming Interface.
From 63.2.3 When Is a File Descriptor Ready?, it says:
Correctly using select() and poll() requires an understanding of
the conditions under which a file descriptor indicates as being ready.
SUSv3…
Rick
- 1,107
- 1
- 16
- 29
2
votes
1 answer
How to display different directory content with Bash select command?
So far I have found some examples of Bash select function usage with logical constructed options or Asterisk one (i.e select s in *). This last one lists all actual directory content.
So I would like to understand the following:
What does *…
artu-hnrq
- 267
- 4
- 14
2
votes
1 answer
bash script select menu
I've many notes gleaned from the web and have written bash scripts to manage them.
I've some scripts working that depend on select to make menus.
Question: in a nested menu context, is it possible to revert to a preceding menu within the script ?…
Tom
- 87
- 7
2
votes
0 answers
Bash menu from screen -ls data
Given the screen data
There are screens on:
27454.world-of-dragons_SERVER (07/05/2018 04:38:56 PM) (Attached)
6223.potato-wod_SERVER (07/05/2018 10:16:12 AM) (Attached)
1681.potato-wod_MASTER (07/04/2018 10:06:20 PM) …
Kreezxil
- 75
- 8
2
votes
2 answers
How do I write a bash script that will let users choose the value of the MIRROR environment variable?
I am presently in the process of writing a Bash function that when invoked will ask users to choose from a list of Sabayon's mirrors, but I would like it if each option could include info on the mirror in question, like its country and connection…
Josh Pinto
- 3,483
- 15
- 52
- 87
2
votes
1 answer
How to force bash to start at index 0 with select output?
Well, even some less-experienced bash users would know meanwhile about the fact that bash arrays would always start with index 0.
However, select will always do its own thing, as the following example shows:
#!/bin/bash
choices=(NONE nyc la chicago…
syntaxerror
- 2,236
- 2
- 27
- 49
1
vote
1 answer
Selecting from various media using awk shell script
I have made a simple backup program for my bin folder. It works.
Code and resultant STDOUT below.
Using rsync to copy from local ~/bin folder to a /media/username/code/bin folder. The code works fine when only one result from mount | grep media but…
Dee
- 33
- 4