Shell 条件判断汇总

-b file            若文件存在且是一个块特殊文件,则为真
-c file            
若文件存在且是一个字符特殊文件,则为真
-d file            
若文件存在且是一个目录,则为真
-e file            
若文件存在,则为真
-f file            
若文件存在且是一个规则文件,则为真
-g file            
若文件存在且设置了SGID位的值,则为真
-h file            
若文件存在且为一个符合链接,则为真
-k file            
若文件存在且设置了"sticky"位的值
-p file            
若文件存在且为一已命名管道,则为真
-r file            
若文件存在且可读,则为真
-s file            
若文件存在且其大小大于零,则为真
-u file            
若文件存在且设置了SUID位,则为真
-w file            
若文件存在且可写,则为真
-x file            
若文件存在且可执行,则为真
-o file            
若文件存在且被有效用户ID所拥有,则为真

-z string          string长度为0,则为真
-n string          
string长度不为0,则为真
string1 = string2  
若两个字符串相等,则为真
string1 != string2 
若两个字符串不相等,则为真

int1 -eq int2      int1等于int2,则为真
int1 -ne int2      
int1不等于int2,则为真
int1 -lt int2      
int1小于int2,则为真
int1 -le int2      
int1小于等于int2,则为真
int1 -gt int2      
int1大于int2,则为真
int1 -ge int2      
int1大于等于int2,则为真

你可能感兴趣的:(shell,String)