码迷,mamicode.com
首页 > 系统相关 > 详细

linux test expression

时间:2018-01-15 12:39:19      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:res   amp   lease   not   pat   tar   $?   pre   oca   

#! /bin/bash
path=/usr/local
[ ! -d "$path" ] && mkdir $path -p
cat <<end
1.[install lamp]
2.[install lnmp]
3.[exit]
pls input the num you want:
end
read -p "please input num:" num
expr num + 1 &>/dev/null
[ $? -ne 0 ] &&{
echo "the num you input must be {1|2|3}"
exit 1
}

[ $num -eq 1 ] && {
echo "start installing lamp."
sleep 2;
[ -x "$path/lamp.sh" ] || {
echo "$path/lamp.sh does not exist or can not be exec."
exit 1
}
$path/lamp.sh
exit $?
}

[ $num -eq 2 ] && {
echo "start install lnmp."
sleep 2;
[ -x "$path/lnmp.sh" ] || {
echo "$path/lnmp.sh does not exists or can not be exec."
exit 1
}
$path/lnmp.sh
exit $?
}

[ $num -eq 3 ] && {
echo bye
exit 10
}

[[ ! $num =~ [1-3] ]] && {
echo "The num you input must be {1|2|3}"
echo "Input wrong"

linux test expression

标签:res   amp   lease   not   pat   tar   $?   pre   oca   

原文地址:http://blog.51cto.com/546136/2061040

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!