LinuxShell宝典 --- 判断与比较
来源:互联网 发布:国际交流软件有哪些 编辑:程序博客网 时间:2024/05/22 05:36
———————————————
$? 对上一次命令执行成功与否成功$?为0
判断文件是否存在且是否为文件
[ -f file ]
判断文件是否存在且是否为可写文件
[ -w file ]
判断文件是否存在且是否为可执行文件
[ -x file ]
判断文件是否存在且是否为可读文件
[ -r file ]
判断文件是否存在且是否为目录文件
[ -d file ]
判断文件是否存在且是否为空文件
[ -s file ]
判断文件是否存在
[ -e file ]
[]和 test功能一样 -a和-o(和,或)
———————————————
整数值比较判断
[ -eq ]
[ “$a” = “0” ]
(( a % 2 == 0 ))
[ -n string ] string 的长度大于0
[ -z string ] string 的长度为0
string1=string2 字符串相等
string1!=string2 字符串不相等
[ int1 -gt int2 ] int1>int2 greater than
[ int1 -ge int2 ] int1>=int2 greater equal
[ int1 -eq int2 ] int1=int2 equal
[ int1 -ne int2 ] int1!=int2 not equal
[ int1 -le int2 ] int1<=int2 less equal
[ int1 -lt int2 ] int1
———————————————
符串比较
[ “
[ -n “
———————————————
if后接的是命令
if rpm -q gcc && id tom||echo “sss”; &&如果前面的命令执行成功则执行&&后的命令否则执行||后面的命令
- LinuxShell宝典 --- 判断与比较
- WindowsBatch与LinuxShell比较[命令比较]
- WindowsBatch与LinuxShell比较[IF/ELSE]
- WindowsBatch与LinuxShell比较[shell循环实例]
- WindowsBatch与LinuxShell比较[batch常见错误]
- LinuxShell宝典 --- sed&awk
- WindowsBatch与LinuxShell比较[变量符号和关键字]
- WindowsBatch与LinuxShell比较[变量符号和关键字]
- WindowsBatch与LinuxShell比较[batchfile之for命令详解]
- WindowsBatch与LinuxShell比较[变量值来自文件或命令]
- WindowsBatch与LinuxShell比较[batchfile之label与shell之函数]
- WindowsBatch与LinuxShell比较[batch常见命令和字符串查找命令find/findstr]
- linuxSHELL学习之数字比较、字符串比较
- Linuxshell字符串截取与拼接
- 日期比较与判断
- linuxshell编程if语句内判断参数
- Linuxshell脚本之if条件判断
- Linuxshell脚本之if条件判断
- 通用简单版循环链表
- maven构建时的注意事项01
- ElasticSearch学习24_elasticsearch2.3 以root用户启动
- jQuery层级选择器
- Codeforces 400D. Dima and Bacteria【并查集+最短路】
- LinuxShell宝典 --- 判断与比较
- 升讯威ADO.NET增强组件(源码):送给喜欢原生ADO.NET的你
- ElasticSearch详解三之——查询
- MVC和MVP
- Apache Commons Compress 压缩zip
- ubuntu14.04安装hadoop 2.7.3
- Conversion to dalvik format failed with error 1
- 4513: [Sdoi2016]储能表
- Android动画-滚动小车