shell 中的条件判断(if else)
来源:互联网 发布:比较好的报刊杂志知乎 编辑:程序博客网 时间:2024/05/16 16:08
传统if 从句子——以条件表达式作为 if条件
if [ 条件表达式 ]
then
command
command
command
else
command
command
fi
条件表达式
- 文件表达式
if [ -f file ] 如果文件存在
if [ -d ... ] 如果目录存在
if [ -s file ] 如果文件存在且非空
if [ -r file ] 如果文件存在且可读
if [ -w file ] 如果文件存在且可写
if [ -x file ] 如果文件存在且可执行
- 整数变量表达式
if [ int1 -eq int2 ] 如果int1等于int2
if [ int1 -ne int2 ] 如果不等于
if [ int1 -ge int2 ] 如果>=
if [ int1 -gt int2 ] 如果>
if [ int1 -le int2 ] 如果<=
if [ int1 -lt int2 ] 如果<
- 字符串变量表达式
If [ $a = $b ] 如果string1等于string2
字符串允许使用赋值号做等号
if [ $string1 != $string2 ] 如果string1不等于string2
if [ -n $string ] 如果string 非空(非0),返回0(true)
if [ -z $string ] 如果string 为空
if [ $sting ] 如果string 非空,返回0 (和-n类似)
- shell 中的条件判断(if else)
- linux shell 条件判断if else, if elif else....
- Linux--Shell脚本(二)条件判断之if else
- Repeater中的条件判断,以及嵌套判断if...else...
- Repeater中的条件判断,以及嵌套判断if...else... .
- js04.if...else条件判断
- python条件判断 if else
- shell脚本中的if判断条件 详解
- 条件判断语句(if...else)与条件编译(#if .... #else ... #endif)
- shell 判断语句 if else
- [shell] if判断条件
- SHELL----IF条件判断
- Shell IF条件判断
- shell--if条件判断
- 自定义标签1——条件判断(if-else)
- python入门(三):条件判断 if elif else
- shell 脚本中的if else
- Linux shell “if else” 与 条件判定
- 安装wamp出现VCRUNTIME140.DLL丢失错误
- 使用spring注入时出现 XXX is not writable or has an invalid setter method
- OpenGL ES 【Opaque 属性在 CAEAGLLayer 中的配置详解】
- QT PK Connect
- XML中的转义字符
- shell 中的条件判断(if else)
- Android实现吸顶效果
- Androidstudio 不运行直接编译生成apk文件
- Java并发编程:volatile关键字解析
- 网站数据统计分析项目之后端脚本解读
- 微信公众号开发_Java(2)--开始开发
- 575. Distribute Candies
- 第一篇博客
- AndroidStudio JDK版本过低编译失败