shell if判断
来源:互联网 发布:java读写xml文件 编辑:程序博客网 时间:2024/05/17 22:28
–b 当file存在并且是块文件时返回真
-c 当file存在并且是字符文件时返回真
-d 当pathname存在并且是一个目录时返回真
-e 当pathname指定的文件或目录存在时返回真
-f 当file存在并且是正规文件时返回真
-g 当由pathname指定的文件或目录存在并且设置了SGID位时返回为真
-h 当file存在并且是符号链接文件时返回真,该选项在一些老系统上无效
-k 当由pathname指定的文件或目录存在并且设置了“粘滞”位时返回真
-p 当file存在并且是命令管道时返回为真
-r 当由pathname指定的文件或目录存在并且可读时返回为真
-s 当file存在文件大小大于0时返回真
-u 当由pathname指定的文件或目录存在并且设置了SUID位时返回真
-w 当由pathname指定的文件或目录存在并且可执行时返回真。一个目录为了它的内容被访问必然是可执行的。
-o 当由pathname指定的文件或目录存在并且被子当前进程的有效用户ID所指定的用户拥有时返回真。
-eq 等于
-ne 不等于
-gt 大于
-lt 小于
-le 小于等于
-ge 大于等于
-z 空串
= 两个字符相等
!= 两个字符不等
-n 非空串
-e filename 如果 filename 存在,则为真
-d filename 如果 filename 为目录,则为真
-f filename 如果 filename 为常规文件,则为真
-L filename 如果 filename 为符号链接,则为真
-r filename 如果 filename 可读,则为真
-w filename 如果 filename 可写,则为真
-x filename 如果 filename 可执行,则为真
filename1 -nt filename2 如果 filename1 比 filename2 新,则为真
filename1 -ot filename2 如果 filename1 比 filename2 旧,则为真
-z string 如果 string 长度为零,则为真
-n string 如果 string 长度非零,则为真
string1 = string2 如果 string1 与 string2 相同,则为真
string1 != string2 如果 string1 与 string2 不同,则为真
num1 -eq num2 等于
num1 -ne num2 不等于
num1 -lt num2 小于
num1 -le num2 小于或等于
num1 -gt num2 大于
num1 -ge num2 大于或等于
test命令用法。功能:检查文件和比较值
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 if 判断语句
- Shell IF判断语句
- shell if判断
- shell中的if判断
- shell中的if判断
- shell的if判断
- [shell] if判断条件
- Shell中if判断
- shell中的if判断
- SHELL----IF条件判断
- shell if 判断语句
- shell if判断
- Shell IF条件判断
- shell if =判断
- shell if 判断
- shell学习-if判断
- shell if 判断
- shell中的if判断
- 常用颜色的RGB值
- ALSA
- NYOJ - 595
- jQuery EasyUI解决输入框在屏幕右侧造成ValidateBox提示信息超出屏幕不可见.
- java - Map使用笔记
- shell if判断
- Unity3D制作编辑器工具教程_1 —— Inspector面板
- 关于Xcode的项目文件夹
- 应聘学校教师笔试中的一些网络试题
- DirectShow使用大全
- C#入门学习-----图书阅读器(WPF 用户控件技术)
- 详解二:CentOS下编译安装PHP开发环境,配置LAMP
- Eclipse中非常有用的快捷键组合
- LINUX让环境变量立即生效的方法