Chinaunix首页 | 论坛 | 博客
  • 博客访问: 338900
  • 博文数量: 222
  • 博客积分: 9349
  • 博客等级: 中将
  • 技术积分: 2135
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-07 13:45
文章分类

全部博文(222)

文章存档

2010年(222)

分类: LINUX

2010-08-08 10:26:28

The condition types that you can use with the test command fall into three types:
 string comparison,
arithmetic comparison, 
and file conditionals. 

String Comparison Result

string1 = string2 True if the strings are equal
string1 != string2 True if the strings are not equal
-n string True if the string is not null
-z string True if the string is null (an empty string)


Arithmetic Comparison Result

expression1 -eq expression2 True if the expressions are equal
expression1 -ne expression2 True if the expressions are not equal
expression1 -gt expression2 True if expression1 is greater than expression2
expression1 -ge expression2 True if expression1 is greater than or equal to
expression2
expression1 -lt expression2 True if expression1 is less than expression2
expression1 -le expression2 True if expression1 is less than or equal to
expression2
! expression True if the expression is false, and vice versa


File Conditional Result

-d file True if the file is a directory
-e file True if the file exists. Note that historically the -e option
has not been portable, so -f is usually used.
-f file True if the file is a regular file
-g file True if set-group-id is set on file
-r file True if the file is readable
-s file True if the file has nonzero size
-u file True if set-user-id is set on file
-w file True if the file is writable
-x file True if the file is executable
阅读(343) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~