[ condition ](注意condition前后要有空格),可以使用$?验证(0为true,>1为false)

两个整数的比较:
=:字符串比较
-lt:小于
-gt:大于
-le:小于等于
-ge:大于等于
-eq:等于
-ne:不等于

按照文件权限进行判断
-r:有读的权限
-w:有写的权限
-x:有执行的权限

按照文件类型进行判断
-e:文件存在
-f:文件存在并且是一个常规的文件,即不是隐藏文件
-d:文件存在并且是一个目录

----------------------------------------------------------------

--------------------------------------------

6.shell判断语句的更多相关文章

  1. 【转】 shell 判断语句

    转自:http://see.sl088.com/wiki/Shell_%E4%B8%AD%E6%8B%AC%E5%8F%B7 test 和 [] test -z string 判定字串是否為 0 ?若 ...

  2. shell 判断语句

    1.字符串判断 str1 = str2 当两个串有相同内容.长度时为真str1 != str2 当串str1和str2不等时为真-n str1 当串的长度大于0时为真(串非空)-z str1 当串的长 ...

  3. shell判断语句

    1.test命令  也可以用[  ]来表示 返回值为0时为true,返回值为1时为false. 例1:str1=aaa,str2=bbb 1)判断字符串是否为空(省略了-n选项,-n选项是不为空,-z ...

  4. linux shell中的条件判断语句

    http://bbs.chinaunix.net/thread-396805-1-1.html shell 判断语句 流程控制 "if" 表达式 如果条件为真则执行then后面的部 ...

  5. shell判断文件,目录是否存在或者具有权限的代码

    核心代码 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的 ...

  6. Unix shell判断和比较

    1.  shell 的$! ,$?, $$,$@ $n        $1 the first parameter,$2 the second... $#        The number of c ...

  7. Linux Shell系列教程之(九)Shell判断 if else 用法

    本文是Linux Shell系列教程的第(九)篇,更多shell教程请看:Linux Shell系列教程 判断语句是每个语言都必不可少的关键语法,Shell命令当然也不例外.今天就给大家介绍下Shel ...

  8. shell判断文件,目录是否存在或者具有权限 (转载)

    转自:http://cqfish.blog.51cto.com/622299/187188 文章来源:http://hi.baidu.com/haigang/blog/item/e5f582262d6 ...

  9. shell判断和比较

    http://blog.chinaunix.net/uid-7553302-id-183648.html 1  shell 的$! ,$?, $$,$@ $n        $1 the first ...

随机推荐

  1. Python——数据类型之set

    本篇主要内容 • set集合的特点 • set集合的建立 • set集合的17个内置函数 • set集合的数学运算符号 1.set集合类型的特点. 1.无序 2.不同元素 3.元素必须不可变.(数字, ...

  2. HDU 4441 Queue Sequence(优先队列+Treap树)(2012 Asia Tianjin Regional Contest)

    Problem Description There's a queue obeying the first in first out rule. Each time you can either pu ...

  3. 《Hadoop基础教程》之初识Hadoop(转载)

    转载自博主:上善若水任方圆http://blessht.iteye.com/blog/2095675 Hadoop一直是我想学习的技术,正巧最近项目组要做电子商城,我就开始研究Hadoop,虽然最后鉴 ...

  4. 【历史】- 一段关于 Unix、Linux 和 Windows 的暗黑史

    “SCO在言语上变得越来越好斗,而且还拒绝展示有关诉讼的任何证据,一切都似乎在表明,SCO只不过是在那里拉虎皮做大旗地狂言乱语.但是,微软决不会轻易放弃这么可以一个利用这些狂言乱语的好机会.”2003 ...

  5. tomcat 路径"/"表示根目录

  6. [BZOJ5417] [NOI2018]你的名字

    Description 小A 被选为了ION2018 的出题人,他精心准备了一道质量十分高的题目,且已经把除了题目命名以外的工作都做好了. 由于ION 已经举办了很多届,所以在题目命名上也是有规定的, ...

  7. [CF15C]Industrial Nim

    题目大意:有$n$个采石场,每行一个$m_i$一个$x_i$,表示第$i$个采石场有$m_i$辆车,这个采石场中车中的石子为从$x_i$开始的自然数.Nim游戏若先手赢输出"tolik&qu ...

  8. [Leetcode] Populating next right pointer in each node ii 填充每个节点的右指针

    Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tre ...

  9. [Leetcode] Recover binary search tree 恢复二叉搜索树

    Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing ...

  10. Android webview “location.replace” 不起作用

    js解决方法: function locationReplace(url){ if(history.replaceState){ history.replaceState(null, document ...