当前第2页 返回上一页
bash脚本中的逻辑与和运算符-a一起使用。下面的shell脚本将展示如何在两个条件之间使用逻辑与(-a)。
1 2 3 4 5 6 7 8 9 10 11 12 | #!/bin/bash
read -p "Enter First Numeric Value: " first
read -p "Enter Second Numeric Value: " second
if [ $ first -le 10-a$ second -gt 20 ]
then
echo "OK"
else
echo "Not OK"
fi
|
逻辑或&与混合使用
下面的示例将介绍如何在单个语句中使用多个逻辑运算符。
1 2 3 4 5 6 7 8 | #!/bin/bash
read -p "Enter Your Number:" i
if [ ( $i -ge 10 -a $i -le 20 ) -o ( $i -ge 100 -a $i -le 200 ) ]
then
echo "OK"
else
echo "Not OK"
fi
|
本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注PHP中文网的Linux教程视频栏目!
以上就是如何在shell脚本中使用逻辑或&和的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
shell编程实战之执行多个目录下的php程序
linux中如何利用shell判断文件或目录是否存在
shell基本语法的介绍与使用
shell script到底是什么?怎么使用?
shell--标准输入输出(read&echo)
linux中的shell命令如何使用
shell如何实现学生成绩管理系统
linux运维之shell变量.md
shell判断字符串为空的方法
shell--标准输入输出(read&echo)
更多相关阅读请进入《shell》频道 >>
转载请注明出处:木庄网络博客 » 如何在shell脚本中使用逻辑或&和