Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1572272
  • 博文数量: 289
  • 博客积分: 11086
  • 博客等级: 上将
  • 技术积分: 3291
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-22 17:06
个人简介

徐小玉的博客。

文章分类

全部博文(289)

文章存档

2023年(6)

2022年(1)

2021年(2)

2020年(9)

2019年(9)

2018年(6)

2017年(10)

2016年(10)

2014年(3)

2013年(4)

2011年(12)

2010年(16)

2009年(14)

2008年(119)

2007年(48)

2006年(20)

我的朋友

分类: LINUX

2016-07-08 13:52:01


String, Integer, and File Testing

Test Operator

Test For

String Test

string1 = string2

String1 is equal to String2 (space surrounding = required)

string1 != string2

String1 is not equal to String2 (space surrounding != required)

string

String is not null

–z string

Length of string is zero

–n string

Length of string is nonzero

 

EXAMPLE

test -n $word      or      [ -n $word ]

test tom = sue      or      [ tom = sue ]


Integer Test

int1 –eq int2

Int1 is equal to int2

int1 –ne int2

Int1 is not equal to int2

int1 –gt int2

Int1 is greater than int2

int1 –ge int2

Int1 is greater than or equal to int2

int1 –lt int2

Int1 is less than int2

int1 –le int2

Int1 is less than or equal to int2

Logical Test

expr1 -a expr2

Logical AND

expr1 -o expr2

Logical OR

! expr

Logical NOT

File Test

–b filename

Block special file

–c filename

Character special file

–d filename

Directory existence

–f filename

Regular file existence and not a directory

–g filename

Set-group-ID is set

–k filename

Sticky bit is set

–p filename

File is a named pipe

–r filename

File is readable

–s filename

File is nonzero size

–u filename

Set-user-ID bit is set

–w filename

File is writable

–x filename

File is executable


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