Skip to main content

Questions tagged [select]

`select` is a keyword in the syntax of the Korn shell language (and other Korn-like shells such as `zsh` or `bash`) used to create menus for terminal user interaction. For creating TUI-based menus and other dialogs in shell scripts, see `whiptail`/`dialog` or `zenity` for GUI ones.

Filter by
Sorted by
Tagged with
0 votes
1 answer
52 views

STDIN breaks my select list

I have a script that can optionally take some input on STDIN and later presents the user with a few select lists. When data is input on STDIN the select list presents but exits without taking input, ...
jesse_b's user avatar
  • 37.6k
3 votes
4 answers
2k views

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=("$...
John Smith's user avatar
0 votes
1 answer
22 views

how to write a commant for output of a particular group?

Reading file prod1.tpr, VERSION 2019.6 (single precision) Reading file prod1.tpr, VERSION 2019.6 (single precision) Select a group of reference atoms and a group of molecules to be ordered: Group ...
PRAMOD KUMAR's user avatar
0 votes
2 answers
326 views

when read buffer size is 2048, it work , but buffer size is 48 or other number, write call will be blocked, why?

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/select.h> #include <fcntl.h> #include <unistd.h> int main(int argc, char* argv[]){ if(...
zhenfei ren's user avatar
2 votes
2 answers
480 views

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&...
j4nd3r53n's user avatar
  • 717
1 vote
1 answer
54 views

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 ...
Dee's user avatar
  • 33
0 votes
1 answer
597 views

Why plus 1 is needed in select system call?

From man select : int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); nfds should be set to the highest-numbered file descriptor in any of ...
whisper's user avatar
  • 11
1 vote
1 answer
6k views

Getting the first/last/nth result from a jq select result

I am trying to find a way to pipe the result of my current script into another command which will leave me with just the last result of the array I get in my select here: jq -r --arg name "$1&...
dschib's user avatar
  • 21
0 votes
2 answers
146 views

Select command showing options without question

Select command is showing options without displaying question. It is displaying question after a choice is made. I have a function as shown below in a script. function start_AppNode { # Define ...
Anil_4_Tibco_Java's user avatar
1 vote
2 answers
8k views

How to select a word under cursor?

For all text editor or application I'm using, I want to select a word under cursor using keyboard shortcut. How can I do it? I tried look around I didn't find anything helpful.
Swapnil's user avatar
  • 251
0 votes
1 answer
2k views

Bash script selecting folder

I am trying to list all the directory latest modified folder first using select, but I am stuck. Let's say I have: Folder1 ThisIsAnotherDir Directory New Directory This IS not_Same Directory When I ...
KpDean's user avatar
  • 3
3 votes
2 answers
3k views

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 ...
Rick's user avatar
  • 1,197
0 votes
0 answers
305 views

Xed : highlight selected text occurences?

I'm using Gnome Xed text editor. Is there a way to auto select all occurrences of currently selected-text across the document. If Xed cant do it, what other linux text editor can do it ? How ?
sten's user avatar
  • 103
2 votes
1 answer
539 views

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 ...
artu-hnrq's user avatar
  • 327
0 votes
1 answer
43 views

How to use select to choose from x files, that contain lists, needed to run set of commands against, in this case curl

I have about 100 lists of URLs used for health checking (200, 300,400,500) but cannot figure out the terminology to ask the question. In advance, I apologize. I want to use a list to choose on of ...
Stryker Cain's user avatar
1 vote
3 answers
381 views

TMOUT within script file misbehaves for the select command. How to fix it?

UPDATE - looks like this is something peculiar with bash 4.3.42 as it works fine with 4.3.46. Leaving this post for those who run into the same issue in future. When I run this command in bash ...
Grzegorz's user avatar
  • 121
1 vote
0 answers
757 views

bash "select" menu script goes into an infinite loop when I close my terminal session

I've got a simple bash menu script that works almost perfect. But for some reason, if I don't exit out of the script using the "Exit" option OR by using CTRL+C BEFORE I close my terminal window, then ...
AppetiteForDestruction's user avatar
3 votes
2 answers
2k views

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 ...
Marko Todoric's user avatar
0 votes
1 answer
386 views

Backspace in select loop

When i use select loop to create a list of options, if i make a mistake during the prompt and want to hit backspace, it doesnt erase the character but displays ^H instead of it. I know in "read" i ...
Marko Todoric's user avatar
0 votes
1 answer
309 views

Lack of a text input field in zenity file selector

I have Debian 9 with xfce and installed zenity to use it to select directory paths. I use it in this way zenity --file-selection --directory The GUI selector looks as below. It has not the text ...
trzczy's user avatar
  • 650
2 votes
0 answers
182 views

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) ...
Kreezxil's user avatar
0 votes
2 answers
22k views

select all text in vi to copy and past in windows

How can I select all text in vi so that I can copy it, and then paste it in notepad on my windows server. I have a file with 3,000 lines in it. I cannot use FTP so I need to copy the text in the ...
user289335's user avatar
1 vote
2 answers
4k views

Bash scripting - exiting submenu

Running into an issue with exiting a submenu. Check it out: function submenu { select submenu1 in "Submenu 1" "Submenu 2" "Submenu 3" "Exit to main menu"; do case $submenu1 in "Submenu 1"...
guestAccountThanks's user avatar
12 votes
4 answers
3k views

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 *;...
DopeGhoti's user avatar
  • 76.9k
10 votes
6 answers
23k views

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 ...
superquanganh's user avatar
-2 votes
1 answer
4k views

Unix shell scripting select and case statement

1) i want to write unix script which is like this echo "Do u want to check application logs ???" select opt in Yes No do case $opt in "Yes") commmands ;; "No") break ...
Giri's user avatar
  • 11
0 votes
2 answers
5k views

What is causing the "syntax error near unexpected token `do'" and how can I fix it?

I keep getting this error: ./install.sh ./install.sh: line 28: syntax error near unexpected token `do' ./install.sh: line 28: ` do' When running this code (a work in progress): # ...
mhulse's user avatar
  • 1,809
0 votes
1 answer
1k views

Skip for loop iteration depending on response to inner select

I have the following bash script, which iterates through all the images in a directory and attempts to determine the date and time it was created using exif. If the exif information is not available, ...
Big McLargeHuge's user avatar
2 votes
2 answers
230 views

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 ...
Josh Pinto's user avatar
  • 3,503
12 votes
2 answers
7k views

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) ...
RICK's user avatar
  • 389
1 vote
1 answer
2k views

How to select read/write time and again? [closed]

This program only waits one time and I don't understand why. Actually, I don't think this question should be put on hold as off-topic. #include <stdio.h> #include <sys/types.h> #include &...
kangear's user avatar
  • 121
2 votes
1 answer
2k views

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 ...
syntaxerror's user avatar
  • 2,306
3 votes
2 answers
4k views

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. ...
Krup's user avatar
  • 45
2 votes
1 answer
2k views

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 ...
Tom's user avatar
  • 87
12 votes
2 answers
26k views

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: ' ...
Sumod's user avatar
  • 607