Linux program - 11.shell script (bash) - (7) Process Control SELECT

xiaoxiao2021-03-06  52

Select Name [in word;] do list; done select as the name is to select an item in Word. As with for, if [in Word;] is omitted, the parameters added later after Script will be used. Example #! / Bin / sh word = "a b c" SELECT I IN $ Word; Do Case $ I I I) ECHO "I am A" ;; b) Echo "I am B" ;; C) ECHO "i AM C ";; *) Break ;;; ESAC DONE execution result [Foxman @ Foxman Bash] # ./select_demo 1) A 2) B 3) C #? 1 I am A 1) A 2) B 3) C # 2 I am b 1) a 2) B 3) C #? 3 I am C 1) a 2) B 3) C #? 4

转载请注明原文地址:https://www.9cbs.com/read-117570.html

New Post(0)