=~shell中if匹配的标准格式,支持正则匹配
#############################################################################################
# File Name: monitor_man.sh
# Author: Finley
# mail: 2306952220@qq.com
# Create Time: Mon 12 Aug 2019 01:38:37 PM CST
#====================================================================================
#!/bin/bash
resettem=$(tput sgr0)
declare -A ssharray
i=0
num=""
for script_file in `ls -I "monitor_man.sh" ./`
do
echo -e "\e[40;35m" "The Script: " ${i} '===>' ${resettem} ${script_file}
ssharray[$i]=${script_file}
numbers="${numbers} | ${i}"
i=$((i+1))
done
while true
do
read -p "Please input a number [ ${numbers} ]:" execshell
if [[ ! ${execshell} =~ ^[0-9]+ ]];
then
exit 0;
fi
/bin/sh ./${ssharray[$execshell]}
done
参考:http://blog.sina.com.cn/s/blog_88d62f1c0102vvwo.html
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190812135327738.png)