shell if else
来源:互联网 发布:vb中ucase是什么意思 编辑:程序博客网 时间:2024/06/06 16:36
例子:
#!/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
- shell if else
- shell if else
- Shell if else语句
- Shell if else语句
- Shell if else语句
- Shell if else语句
- Shell if else语句
- Shell if else语句
- Shell if else语句
- shell if-else
- Shell if else命令
- shell-007: if elif else
- linux shell ---if...else...fi
- shell语法if else elif
- shell的if/else框架
- linux shell中 if else
- 十四、Shell if else语句
- shell 脚本 if elseif else
- Hive 基础命令和 TPC-H Benchmark
- SSL 与 数字证书 的基本概念和工作原理
- openoffice --替换文本的宏
- mac系统如何显示和隐藏文件 和 删除SVN隐藏文件
- Iceberg 打包工具使用说明
- shell if else
- JdbcTemplate与事务
- 情景模式
- SqlServer附加数据库问题集锦(一)
- redis中 hash类型的操作命令
- Andriod 对话框
- 关于把数据保存到oracle中的blob字段
- javascript根据鼠标和键盘复制页面内容验证是否登录
- 新建ArcGIS Project for Android项目失败解决方案