shell 测试命令
2024-08-31 10:46:55
一、使用 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
最新文章
- How to reset password for unknow root
- We have a problem with promises
- linux命令分享(四):iostat
- C#编程总结(七)数据加密——附源码
- Oracle连接超时
- leetcode算法思想快速一览
- 团队开发-极速蜗牛-NABC模型
- ZOJ 4114 Detect the Virus(AC自动机)
- java 动态获取web应用的部署路径
- 学习笔记: JavaScript/JQuery 的cookie操作
- [故障公告] 13:52-14:03,访问量突增,博客web服务器CPU 100%
- flask WTForms源码分析及自定义WTForms
- Tomcat配置Web默认页面
- JavaScript&#183;DOM,BOM
- Codeforces.954I.Yet Another String Matching Problem(FFT)
- eclipse 关联 Maven本地仓库的配置
- Bresenham直线算法与画圆算法
- 用Docker构建分布式Redis集群
- git删除本地保存的账号和密码
- git rebase 的作用
热门文章
- 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms
- 【codeforces 805C】Find Amir
- 计算机网络系统--TCP/IP OSI模型
- JavaSript 基础学习笔记
- [Linux]第五部分-Linux系统管理员
- 60款开源云应用【Part 3】(60 Open Source Apps You Can Use in the Cloud)
- Spring使用HibernateDaoSupport操作数据
- javascript系列-class12.事件
- Redis学习笔记(十一) 命令进阶:Connection(连接)
- vue-cli搭建项目结构及引用bootstrap