摘自http://www.comptechdoc.org/os/linux/usersguide/linux_ugshellpro.html

Tests

There is a function provided by bash called test which returns a true or false value depending on the result of the tested expression. Its syntax is:

test expression

It can also be implied as follows:

[ expression ]

The tests below are test conditions provided by the shell:

  • -b file = True if the file exists and is block special file.
  • -c file = True if the file exists and is character special file.
  • -d file = True if the file exists and is a directory.
  • -e file = True if the file exists.
  • -f file = True if the file exists and is a regular file
  • -g file = True if the file exists and the set-group-id bit is set.
  • -k file = True if the files' "sticky" bit is set.
  • -L file = True if the file exists and is a symbolic link.
  • -p file = True if the file exists and is a named pipe.
  • -r file = True if the file exists and is readable.
  • -s file = True if the file exists and its size is greater than zero.
  • -s file = True if the file exists and is a socket.
  • -t fd = True if the file descriptor is opened on a terminal.
  • -u file = True if the file exists and its set-user-id bit is set.
  • -w file = True if the file exists and is writable.
  • -x file = True if the file exists and is executable.
  • -O file = True if the file exists and is owned by the effective user id.
  • -G file = True if the file exists and is owned by the effective group id.
  • file1 –nt file2 = True if file1 is newer, by modification date, than file2.
  • file1 ot file2 = True if file1 is older than file2.
  • file1 ef file2 = True if file1 and file2 have the same device and inode numbers.
  • -z string = True if the length of the string is 0.
  • -n string = True if the length of the string is non-zero.
  • string1 = string2 = True if the strings are equal.
  • string1 != string2 = True if the strings are not equal.
  • !expr = True if the expr evaluates to false.
  • expr1 –a expr2 = True if both expr1 and expr2 are true.
  • expr1 –o expr2 = True is either expr1 or expr2 is true.

linux 命令 之判断表达式的更多相关文章

  1. Linux 命令小记

    1. pidof 进程名 :获取进程的pid,例如 pidof memcached 得到5333 2. unset Shell变量 :取消设置一个shell变量,从内存和shell的导出环境中删除它, ...

  2. LINUX命令总结 -------来自 水滴娃娃 的CSDN

    LINUX命令总结 标签: LINUX命令总结 2014-01-27 15:54 41039人阅读 评论(1) 收藏 举报  分类: linux(1)  版权声明:本文为博主原创文章,未经博主允许不得 ...

  3. Linux命令自己总结

    对于每一个Linux学习者来说,了解Linux文件系统的目录结构,是学好Linux的至关重要的一步.,深入了解linux文件目录结构的标准和每个目录的详细功能,对于我们用好linux系统只管重要,下面 ...

  4. 嵌入式开发应该掌握的一些Linux命令

    Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命令.要想真正理解Linux系统, ...

  5. linux 命令总结(转载)

    linux 命令总结(转载) 1. 永久更改ip ifconfig eth0 新ip 然后编辑/etc/sysconfig/network-scripts/ifcfg-eth0,修改ip 2.从Lin ...

  6. 来聊一聊不low的Linux命令——find、grep、awk、sed

    前几天面试,被一位面试官嫌弃了"你的Linux命令有点low".被嫌弃也挺正常的,因为我的简历写的我自己都有点看不下去:了解Linux常用命令,如ls,tail -f等命令,基本满 ...

  7. 工作中常用的 Linux 命令

    awk 示例: env变量值如下,需要获得pkg_url的链接值: {"name": "michael", "sex": "mal ...

  8. Linux命令行文本工具

    浏览文件 cat 查看文件内容 more 以翻页形式查看文件内容(只能向下翻页) less 以翻页形式查看文件内容(可以上下翻页) head 查看文件的头几行(默认10行) tail 查看文件的尾几行 ...

  9. [转帖]Linux命令中特殊符号

    Linux命令中特殊符号 转自:http://blog.chinaunix.net/uid-16946891-id-5088144.html   在shell中常用的特殊符号罗列如下:# ; ;; . ...

随机推荐

  1. 禁用Windows重复数据删除

    重复数据删除,可以减少磁盘占用,但使用不当也有可能增加IO,另外,也为此功能会将硬盘分块,所以当硬盘占用较高时,进行碎片整理也比较困难,所以有时需要禁用掉重复数据删除功能,并解除重复数据的优化,可以通 ...

  2. JsonResult作为Action返回值时的错误

    JsonResult作为Action返回值时的错误   System.InvalidOperationException: This request has been blocked because ...

  3. sqlServer、MySql批量操作插件

    SqlServer: 1.EntityFramework.BulkInsert  .只适用于SqlServer.要想实现MySql批量插入,得自己实现一些方法,注册驱动之类,暂时没能力. 2.z.en ...

  4. 【WPF】 Timer与 dispatcherTimer 在wpf中你应该用哪个?

    源:Roboby 1.timer或重复生成timer事件,dispatchertimer是集成到队列中的一个时钟.2.dispatchertimer更适合在wpf中访问UI线程上的元素 3.Dispa ...

  5. 详解C#中的反射

    反射(Reflection) 2008年01月02日 星期三 11:21 两个现实中的例子:1.B超:大家体检的时候大概都做过B超吧,B超可以透过肚皮探测到你内脏的生理情况.这是如何做到的呢?B超是B ...

  6. C#工程引用自定义目录的DLL

    在App.config里配置: <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-mi ...

  7. Tomcat基于虚拟路径的发布和web.xml配置

    <Connector port="8888" protocol="HTTP/1.1" connectionTimeout="20000" ...

  8. staxon实现json和xml互转

    pom.xml: <dependency> <groupId>de.odysseus.staxon</groupId> <artifactId>stax ...

  9. 如何做好PMO,PMO分哪些方面?

    谢邀! 理论的东西,中国PMO大会的帐号说的很全面了. 我分享一些个人感受.失败经验: 我曾帮助中国区COO创立过PMO并且运营两年,COO离职后终止. 成功案例: 我曾看过总部老大们设立Busine ...

  10. 精灵方向移动问题[math.floor]

    local xd = math.cos(math.rad(self._direction));--self._direction方向角度 local yd = math.sin(math.rad(se ...