您的位置:首页 > 运维架构 > Shell

linux shell 中比较数字 、字符串 大小

2017-04-21 20:59 253 查看
数字的比较:

-eq 相等(equal)

-ne 不等(not equal)

-gt 大于(greater than)

-lt 小于(less than)

-ge 大于等于 (greater than or equal)

-le 小于等于 (less than or equal)

字符串的比较:

[
$str1
=
$str2
] 等于

[
$str1
!=
$str2
] 不等于

[ -z
$str
] 空字符串返回true

[ -n
$str
] 或者 [
$str
] 非空字符串返回true
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell linux shell