文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Linux shell 条件表达式

Linux shell 条件表达式

时间:2010-05-04  来源:大方无隅

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 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载