Chinaunix首页 | 论坛 | 博客
  • 博客访问: 286990
  • 博文数量: 70
  • 博客积分: 485
  • 博客等级: 下士
  • 技术积分: 632
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-25 08:55
文章分类

全部博文(70)

文章存档

2014年(47)

2013年(1)

2012年(22)

我的朋友

分类: LINUX

2012-11-06 22:18:32

 一:文件测试:

语法:text option file 或者 option file

-b file file存在且是块文件时返回真

-c file file存在且是字符文件时返回真

-d pathname pathname存在并且是一个目录时返回真

-e pathname pathname指定的是目录或者文件时返回真

-f file file存在并且是正规文件时返回真

-g pathname 当由pathname指定的文件或者目录存在并且设置了SGID位时返回真

-h file file存在并且是符号链接文件时返回真

-k pathname 当由pathname存在并且设置了粘滞位时返回真

-p file file存在并且是命名管道时返回真

-r pathname 当由pathname存在并且可读时返回真

-s file file存在并且文件大小大于0时返回真

-u pathname 当由pathname指定的文件或者目录存在并且设置了SUID位时返回真

-w pathname 当由pathname指定的文件或者目录存在并且可写时返回真

-x pathname 当由pathname指定的文件或者目录存在并且可执行时返回真

-o pathname 当由pathname指定的文件或者目录存在并且被当前进程的有效用户ID所指定时拥有返回真

二:字符串的比较:

Text命令的字符串比较选项

-z str str长度为0时返回真

-n str str长度不为0时返回真

Str1 = str2 str1str2相等时返回真

Str1 = str2 str1str2不相等时返回真

在比较没有值的变量时最好用“”来引起

三:数字的比较

Text int1 op int2 或【 int1 op int2

-eq 等于 –ne 不等于 –lt 小于 –le 小于等于

-gt 大于 –ge 大于等于

注意:如果int1 int2 是一个字符串而不是整数,他就被作为0来对待

四:符合表达式

内建:Text exp1 op exp2或【 expr1 op expr2

expr expr为假时返回真

Expr1 –a expr2 expr1expr2都为真是返回真

Expr1 –o expr2 expr1 expr2为真时返回真

 

阅读(2323) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~