shell判断文件,目录是否存在或者具有权限
来源:互联网 发布:python编程培训 编辑:程序博客网 时间:2024/04/30 23:53
shell判断文件,目录是否存在或者具有权限
#!/bin/sh
NovaPath=”/var/log/httpd/”
NovaFile=”/var /log/httpd/access.log”
#这里的-x 参数判断$NovaPath是否存在并且是否具有可执行权限
if [ ! -x "$NovaPath"]; then
mkdir “$NovaPath”
fi
#这里的-d 参数判断$NovaPath是否存在
if [ ! -d "$NovaPath"]; then
mkdir “$NovaPath”
fi
#这里的-f参数判断$NovaFile是否存在
if [ ! -f "$NovaFile" ]; then
touch “$NovaFile”
fi
#其他参数还有-n,-n是判断一个变量是否是否有值
if [ ! -n "$NovaVar" ]; then
echo “$NovaVar is empty”
exit 0
fi
#两个变量判断是否相等
if [ "$var1" = "$var2" ]; then
echo ‘$var1 eq $var2′
else
echo ‘$var1 not eq $var2′
fi
0 0
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- [zz] shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- maven下面怎么使用lib下的Jar包
- PHP实例解析:实现给上传图片加水印图案
- android中的系统广播
- 数模+lingo
- MINI2440启动配置文件/etc/init.d/rcS文件分析
- shell判断文件,目录是否存在或者具有权限
- Android: 在onCreate()中获得对象尺寸
- 在linux下安装mysql服务
- hdu 1078 搜索
- 树莓派Shell脚本文件
- FFMPEG教程1_解码后保存图片(使用2014年新SDK重新整理编译通过)
- adb 不是内部或外部命令
- flash builder的配色方案
- Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules