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

1、字符串测试

test str1 = str2    //测试字符串是否相等
test str1 != str2 //测试字符串是否不相等
test str1 //测试字符串是否部位空
test -n str1 //测试字符串是否部位空
test -z str1 //测试字符串是否为空

2、整数测试

test int1 -eq int2    //测试整数是否相等
test int1 -ne int2 //测试整数是否不相等
test int1 -gt int2 //测试 int1 是否 > int2
test int1 -ge int2 //测试 int1 是否 >= int2
test int1 -lt int2 //测试 int1 是否 < int2
test int1 -le int2 //测试 int1 是否 <= int2

3、文件测试

test -d file    //指定文件是否是目录
test -f file //指定文件是否是常规文件
test -x file //指定文件是否可执行
test -r file //指定文件是否可读
test -w file //指定文件是否写
test -a file //指定文件是否存在
test -s file //文件大小是否不是 0

最新文章

  1. How to reset password for unknow root
  2. We have a problem with promises
  3. linux命令分享(四):iostat
  4. C#编程总结(七)数据加密——附源码
  5. Oracle连接超时
  6. leetcode算法思想快速一览
  7. 团队开发-极速蜗牛-NABC模型
  8. ZOJ 4114 Detect the Virus(AC自动机)
  9. java 动态获取web应用的部署路径
  10. 学习笔记: JavaScript/JQuery 的cookie操作
  11. [故障公告] 13:52-14:03,访问量突增,博客web服务器CPU 100%
  12. flask WTForms源码分析及自定义WTForms
  13. Tomcat配置Web默认页面
  14. JavaScript&#183;DOM,BOM
  15. Codeforces.954I.Yet Another String Matching Problem(FFT)
  16. eclipse 关联 Maven本地仓库的配置
  17. Bresenham直线算法与画圆算法
  18. 用Docker构建分布式Redis集群
  19. git删除本地保存的账号和密码
  20. git rebase 的作用

热门文章

  1. 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms
  2. 【codeforces 805C】Find Amir
  3. 计算机网络系统--TCP/IP OSI模型
  4. JavaSript 基础学习笔记
  5. [Linux]第五部分-Linux系统管理员
  6. 60款开源云应用【Part 3】(60 Open Source Apps You Can Use in the Cloud)
  7. Spring使用HibernateDaoSupport操作数据
  8. javascript系列-class12.事件
  9. Redis学习笔记(十一) 命令进阶:Connection(连接)
  10. vue-cli搭建项目结构及引用bootstrap