1)判断表达式

if test  (表达式为真)

if test !表达式为假

test 表达式1 –a 表达式2                  两个表达式都为真

test 表达式1 –o 表达式2                 两个表达式有一个为真

2)判断字符串

test –n 字符串                                   字符串的长度非零

test –z 字符串                                    字符串的长度为零

test 字符串1=字符串2                    字符串相等

test 字符串1!=字符串2               字符串不等

3)判断整数

test 整数1 –eq 整数2                        整数相等

test 整数1 –ge 整数2                        整数1大于等于整数2

test 整数1 –gt 整数2                         整数1大于整数2

test 整数1 –le 整数2                         整数1小于等于整数2

test 整数1 –lt 整数2                          整数1小于整数2

test 整数1 –ne 整数2                        整数1不等于整数2

4)判断文件

test  File1 –ef  File2                            两个文件具有同样的设备号和i结点号

test  File1 –nt  File2                            文件1比文件2 新

test  File1 –ot  File2                            文件1比文件2 旧

test –b File                                           文件存在并且是块设备文件

test –c File                                           文件存在并且是字符设备文件

test –d File                                           文件存在并且是目录

test –e File                                           文件存在

test –f File                                            文件存在并且是正规文件

test –g File                                           文件存在并且是设置了组ID

test –G File                                           文件存在并且属于有效组ID

test –h File                                           文件存在并且是一个符号链接(同-L)

test –k File                                           文件存在并且设置了sticky位

test –b File                                           文件存在并且是块设备文件

test –L File                                           文件存在并且是一个符号链接(同-h)

test –o File                                           文件存在并且属于有效用户ID

test –p File                                           文件存在并且是一个命名管道

test –r File                                            文件存在并且可读

test –s File                                           文件存在并且是一个套接字

test –t FD                                             文件描述符是在一个终端打开的

test –u File                                           文件存在并且设置了它的set-user-id位

test –w File                                          文件存在并且可写

test –x File                                           文件存在并且可执行

shell test用法的更多相关文章

  1. Shell常见用法小记

    shell的简单使用 最近发现shell脚本在平常工作中简直算一把瑞士军刀,很多场景下用shell脚本能实现常用的简单需求,而之前都没怎么学习过shell,就趁机把shell相关的语法和常见用法总结了 ...

  2. Linux shell ${}简单用法

    转自:Linux shell ${}简单用法 为了完整起见,我这里再用一些例子加以说明 ${ } 的一些特异功能:假设我们定义了一个变量为:file=/dir1/dir2/dir3/my.file.t ...

  3. shell eval用法

    转自:http://blog.csdn.net/w_ww_w/article/details/7075867 eval可读取一连串的参数,然后再依参数本身的特性来执行.eval是shell内建命令,可 ...

  4. shell 函数用法

    近期在学习shell编程方面的知识,写的不怎么好,请大家多多指点,下面给大家分享一下shell函数的用法. 我们为什么要用shell函数? 简单的说,函数的作用就是把程序多次调用相同的代码部分定义成一 ...

  5. [shell]shell 中| && || () {} 用法以及shell的逻辑与或非

    转自:https://www.jianshu.com/p/617c1ee1e46e | 运算符 管道符号,是unix一个很强大的功能,符号为一条竖线:"|".用法: command ...

  6. shell简单用法笔记(shell中数值运算)二

    shell中变量值,如果不手动指定类型,默认都是字符串类型: 例如: a= b= c=$a+#b echo $c 结果会输出:123+456 shell中,如果要进行数值运算,可以通过一下方法: 方法 ...

  7. shell简单用法笔记(一)

    一.linux中主要用的bash shell:查看linux系统中支持的shell种类可用: vim /etc/shell 执行shel脚步的方式: 1.赋予脚步可执行权限,使用相对或绝对路径调用该脚 ...

  8. shell expr用法

    expr 计算整数变量值 使用方法如下: linux-zpycfm:/home/test/shell # s=+ -bash: +: command not found linux-zpycfm:/h ...

  9. shell基本用法

    shell是一个命令行解释器,它接收应用程序/ 用户命令,然后调用操作系统内核:功能强大的编程语言: 1. Shell解析器 Linux提供的Shell解析器有: [kris@hadoop datas ...

  10. shell -- sed用法

    sed是一个很好的文件处理工具,本身是一个管道命令,主要是以行为单位进行处理,可以将数据行进行替换.删除.新增.选取等特定工作,下面先了解一下sed的用法sed命令行格式为:         sed ...

随机推荐

  1. 最实用的IT类网站及工具大集合

    1.聚合数据 大家在开发过程中,可能会用到各种各样的数据,想找一些接口来提供一些数据.比如天气预报查询,火车时刻表查询,彩票查询,身份证查询等等.有了这个接口,直接调用即可.各种各样的API接口满足你 ...

  2. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  3. BZOJ 2154: Crash的数字表格 [莫比乌斯反演]

    2154: Crash的数字表格 Time Limit: 20 Sec  Memory Limit: 259 MBSubmit: 2924  Solved: 1091[Submit][Status][ ...

  4. Spring 事务详解

    实现购买股票案例: 一.引入JAR文件: 二.开始搭建分层架构---创建账户(Account)和股票(Stock)实体类 Account: ? 1 2 3 4 5 6 7 8 9 10 11 12 1 ...

  5. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  6. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  7. [LeetCode] Shortest Word Distance 最短单词距离

    Given a list of words and two words word1 and word2, return the shortest distance between these two ...

  8. CoreOS和Docker入门

    转载自: http://www.oschina.net/translate/coreos_and_docker_first_steps?cmp CoreOS是一个基于Linux,systemd和Doc ...

  9. Spring Aspectj切入点语法定义

    在使用spring框架配置AOP的时候,pointcut"切入点" 例如定义切入点表达式 execution(* com.sample.service.impl..*.*(..)) ...

  10. iframe 跨域相互操作

    我们在开发后台管理系统时可能会经常要跟 iframe 打交道,因为现在大部分后台管理系统都是页面内嵌iframe,所以有时候两者之间就难免要互相通信,但浏览器为了安全的原因,所以就禁止了不同域的访问, ...