linux shell判断文件,目录是否存在或者具有权限
来源:互联网 发布:软件过程管理 pdf 编辑:程序博客网 时间:2024/06/06 05:29
在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结:#!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$myPath"]; then mkdir "$myPath" fi #这里的-d 参数判断$myPath是否存在 if [ ! -d "$myPath"]; then mkdir "$myPath" fi #这里的-f参数判断$myFile是否存在 if [ ! -f "$myFile" ]; then touch "$myFile" fi #其他参数还有-n,-n是判断一个变量是否是否有值 if [ ! -n "$myVar" ]; then echo "$myVar is empty" exit 0 fi #两个变量判断是否相等 if [ "$var1" = "$var2" ]; then echo '$var1 eq $var2' else echo '$var1 not eq $var2' fi
阅读全文
0 0
- linux shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- [zz] shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- shell判断文件,目录是否存在或者具有权限
- return "cartSuccess" 和 return "redirect:/cart/cart.html" 的区别
- Jsonrpc项目综述
- 599. Minimum Index Sum of Two Lists
- 【C语言】在字符串中找出第一个只出现一次的字符,输入“abaccdeff”,则输出'b'
- Git工作区,暂存区,远程仓库及分支管理
- linux shell判断文件,目录是否存在或者具有权限
- 北大“人工智能前沿与产业趋势”课程整理02
- C++11之std::function和std::bind
- 基于信号处理的在线云评测+社区系统( 5)
- 八、反射
- hdu 5289 ST表+双指针或者优先队列或者multiset
- JavaScript中运算符的优先级汇总
- Shell使用总结(一)
- Struts2中default.properties常量默认配置文件详解,以及修改常量方式