新建一个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
运行测试日志如下:
自由互联热门推荐:PDF电子发票识别软件,一键识别电子发票并导入到Excel中!10大顶级数据挖掘软件!人工智能的十大作用!- [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: