if [ -f /lianxi/hosts ]
then
echo hosts is exist
exit 1 #跳出程序,终止执行后面的命令。返回值为1
else
touch /lianxi/hosts
echo hosts is create ok
fi
==============================================
##if语法 -z command 表示当command为空时
if [ -z $b ]
==============================================
判断文件是否存在且是否为目录文件
[ -d file ]
==============================================
转载于:https://www.cnblogs.com/blog-acf/p/4265671.html