Chinaunix首页 | 论坛 | 博客
  • 博客访问: 600804
  • 博文数量: 80
  • 博客积分: 3315
  • 博客等级: 中校
  • 技术积分: 697
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-27 12:46
文章分类

全部博文(80)

文章存档

2014年(3)

2013年(3)

2012年(5)

2011年(19)

2010年(50)

我的朋友

分类:

2010-05-04 21:38:41

表达式和类型

Conditional judge

the result of conditional judge is  true  or false.

0 --- true  and  Non-0  --- false

test  cond_expr or [ cond_expr ]

cond_expr:

file type and the permission of the file

string content and the length

compare values


Expression

expression If expression is true, !expression is false

expression1 –a expression2 Both expression1 and expression2 are true

Expression1 –o expression2 Either expression1 or expression2 are true


String

-n string The length of string is nonzero

-z string The length of string is zero

string1 = string2 The strings are equal

string1 != string2 The strings are not  equal

string1 The string1 is not null


Integer

interger1 –eq interger2 Interger1 is equal to interger2

interger1 –ge interger2 Interger1 is greater than or equal to interger2

interger1 –gt interger2 Interger1 is greater than interger2

interger1 –le interger2 Interger1 is less than or equal to interger2

interger1 –lt interger2 Interger1 is less than interger2

interger1 –ne interger2 Interger1 is not equal to interger2


File

file1 –ef file2 file1 and file2 have the same device and inode number

file1 –nt file2 file1 is newer(modification date) than file2

file1 –ot file2 file1 is older than file2

-b –c –d file file exits and is block/character/directory type

-e file exits

-s file exists and the length bigger than 0

-f file is a normal file

-r –w -x file exits and is readable/writable/executable

-L  -h file exists and is a symbolic link 

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