Linux shell select implements menu selection
How to use the select statement (produce menu selection)
grammar:
select variable name in seq variable do action done
Example:
#!/bin/sh select ch in "begin" "end" "exit" do case $ch in "begin") echo "start something" ;; "end") echo "stop something" ;; "exit") echo "exit" break; ;; *) echo "ignorant" ;; esac done;
running result:
yuxuecheng@linux:~/shellSource> ./select_test.sh 1) begin 2) end 3) exit #? 1 start something #? 2 stop something #? 4 ignorant #? begin ignorant #? 3 exit
Description: select is a circular selection, generally used with case statements.