新建一个test.sh文件
- #!/bin/sh
- echo "1 : For Test"
- echo "2 : For nohup &"
- whiletrue
- do
- echo -n "please enter the number:"
- read line
- echo "$line"
- if[[ $line ="1"]];then
- echo "For Test"
- elif[[ $line ="2"]];then
- echo "For nohup &"
- else
- echo "can not find command"
- fi
- done
运行测试日志如下:
- [root@master batch]# sh test.sh
- 1:ForTest
- 2:For nohup &
- please enter the number:1
- 1
- ForTest
- please enter the number:2
- 2
- For nohup &
- please enter the number:3
- 3
- can not find command
- please enter the number:ss
- ss
- can not find command
- please enter the number:
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Linux shell脚本读取用户输入的参数 - Python技术站