shell编程-条件判断式
2016-01-18 11:27
337 查看
条件判断式主要有以下6种类型:
[root@hadoop200 test]# ls -l total 8 drwxr-xr-x 2 root root 4096 Jan 17 19:28 shell -rw-r--r-- 1 root root 4 Jan 17 19:29 test.sh [root@hadoop200 test]# [ -d test.sh ] && echo "yes" || echo "no" no [root@hadoop200 test]# [ -f test.sh ] && echo "yes" || echo "no" yes [root@hadoop200 test]# [ -e test.sh ] && echo "yes" || echo "no" yes [root@hadoop200 test]#
[root@hadoop200 test]# a=10 [root@hadoop200 test]# b=20 [root@hadoop200 test]# [ $a -eq $b ] && echo "yes" || echo "no" no [root@hadoop200 test]# [ $a -ne $b ] && echo "yes" || echo "no" yes [root@hadoop200 test]# [ $a -gt $b ] && echo "yes" || echo "no" no [root@hadoop200 test]# [ $a -lt $b ] && echo "yes" || echo "no" yes [root@hadoop200 test]# [ $a -ge $b ] && echo "yes" || echo "no" no [root@hadoop200 test]# [ $a -le $b ] && echo "yes" || echo "no" yes
相关文章推荐
- shell编程-运算符
- bash脚本语言
- shell脚本报错"expr: syntax error" 解决方案
- Hadoop错误10_bash: hadoop: command not found问题解决
- shell脚本笔记
- 【Xshell】连接【Ubuntu】电脑之ssh设置
- FreeBSD更换默认csh为bash
- Linux Shell的信号trap功能你必须知道的细节
- 认识与学习bash
- 基于uiautomator与shell的自动化测试工具
- grub密码
- Linux Shell笔记之sed
- shell 编程入门
- shell编程-环境变量配置文件的功能
- op08-bash scripts config files
- Shell脚本学习笔记
- Bash Promot
- java调用linux中的shell脚本并返回执行结果
- PuTTY?Bash?Out了!!!终端应该这么玩~
- shell脚本须知