新建文件
sudo vi test.sh
写入如下内容:
#!/bin/bash echo "What is your favourite OS?" select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do break; done echo "You have selected $var"
赋予执行权限
sudo chmod +x test.sh
执行
./test.sh
输出:
What is your favourite OS? 1) Linux 2) Gnu Hurd 3) Free BSD 4) Other #? 2 You have selected Gnu Hurd