您好,登錄后才能下訂單哦!
select單獨使用
cat select01.sh #!/bin/bash echo "Which car do you prefer?" select CAR in Benz Audi VolksWagen do break done echo "You chose $CAR"
運行結果
sh select01.sh Which car do you prefer? 1) Benz 2) Audi 3) VolksWagen #? 1 You chose Benz
select和case結合使用
cat select02.sh #!/bin/bash select DAY in Mon Tue Wed Thu Fri Sat Sun do case $DAY in Mon) echo "Today is Monday";; Tue) echo "Today is Tuesday";; Wed) echo "Today is Wednesday";; Thu) echo "Today is Thursday";; Fri) echo "Today is Friday";; Sat|Sun) echo "You can have a rest today";; *) echo "Unknown input ,exit now" && break;; esac done
select結合case使用
sh select02.sh 1) Mon 2) Tue 3) Wed 4) Thu 5) Fri 6) Sat 7) Sun #? 1 Today is Monday #? 6 You can have a rest today #? 8 Unknown input ,exit now
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。