shell中test的使用

#/secondin/secondfirstsh
echo “please enter two numseconder”
read first
read second
if test $first -eq $second
then echo “NO.1 = NO.2″
elif test $first -gt $second //判定其是否大于
then echo “NO.1 > NO.2″

else echo “NO.1 < NO.2″
fi
例2.查找/root/目录下是否存在该文件
#/secondin/secondfirstsh
echo “enter first file nfirstme:”
read first
if test  -e /root/$first  //其中的-e 代表存在这个文件
then echo “the file is exist!”
else echo “the file is not exist!”
fi

posted @ 2015-07-07 17:16  haoxing990  阅读(254)  评论(0编辑  收藏  举报