shell中if使用方法
1、if的语法结构
if [ condition ]
then
statements
[elif condition
then statements. ..]
[else
statements ]
fi

2、整数比较

3、字符串比较

4、权限判断,用于判断文件对当前用于的权限
-r 有读的权限
-w 有写的权限
-x 有执行的权限
5、if对于文件的判断

6、脚本实例
脚本一:
#!/bin/sh
echo "Please input a integer:"
read integer1
if [ "$integer1" -lt 30 ]
then echo "The integer which you input is lower than 30."
fi
脚本二:
if [ -f 023.txt ];then
echo "file is exist"
else
touch 023.txt
fi
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:93
阅读量:39
阅读量:167
阅读量:101
阅读量:111