select

noun

say it: “suh-LEKT” /səˈlɛkt/

A bash command that shows a numbered menu of choices and stores the one the user picks.

What does select do in bash?

select turns a list of words into a numbered menu. The person types a number, the chosen word goes into the variable, and the lines between do and done run. PS3 sets the question, and break ends the menu after one choice.

PS3="Back up which file? "
select file in *.txt; do
  ./backup.sh "$file"
  break
done

In a sentence

  • “With select, the script lists the .txt files as a numbered menu.”
  • “Sam typed 4 at the select menu, and the script backed up that file.”

Level: Apprentice · More Unix terms at this level

Updated

In other subjects