>测试两个整数直接的关系
" -eq " 等于
" -ne " 不等于
" -gt " 大于
" -ge " 大于等于
" -lt " 小于
" -le " 小于等于
"-r file" 用户可读为真
"-w file" 用户写为真
"-x file" 用户可执行为真
"-f file" 文件为正规文件
"-d file "文件为目录
"-c file" 文件为字符特殊文件为真
"-b file"文件为块特殊文件为真
"-s" file 文件大小非0
"-t file"
>(and、or、not)
-a 与
-o 或
! 非
用以上学的写个小东西判断如果如果这个文件夹存在一是文件夹存在,如果不存在建立文件夹。
#!/bin/sh
for ((i=1;i<=10;i++));do
if [ ! -d haha$i]
then
mkdir -p haha$i
else
echo "haha$i" " 已经存在"
fi
done
>空命令
在Bsh中 用 : 代表空命令,就是充个数,什么都不做
> 嵌套if语句和elif结构
检查条件
#!/bin/sh
if command
then
command
else
if command
then
command
else
if command
then
fi
fi
fi
>elif 语句
if command
then
command
elif command
then
command
elif comand
then
command
fi
上面介绍的嵌套if语句和elif语句完全相同的功能!
转载于:https://blog.51cto.com/mecho/191202