首页 > 系统服务 > 详细

shell test判断命令

时间:2018-04-17 20:34:38      阅读:162      评论:0      收藏:0      [点我收藏+]

判断命令test

使用test命令可以对文件,字符串等进行测试,一般配合控制语句使用,如while,if,case

"字符串测试"
 ? test str1==str2 测试字符串是否相等
 ? test str1!-str2 测试字符串是否不相等
 ? test str1 测试字符串是否不为空
 ? test -n str1 测试字符串是否不为空
 ? test -z str1 测试字符串是否为空
 ? 
"int 测试"
 ? test int1 -eq int2 测试整数是否相等
 ? test int1 -ne int2 测试整数是否不相等
 ? test int1 -ge int2 测试整数int1是否>=int2
 ? test int1 -gt int2 测试整数int1是否>int2
 ? test int1 -le int2 测试整数int1是否<=int2
 ? test int1 -lt int2 测试整数int1是否<int2
?
"文件测试"
 ? ?test -d file 指定文件是否目录
 ? ?test -f file 指定文件是否常规文件
 ? ?test -x file 指定文件是否可执行
 ? ?test -r file 指定文件是否可读
 ? ?test -w file 指定文件是否可写

shell test判断命令

原文:https://www.cnblogs.com/ssgao/p/8869676.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!