本文摘自PHP中文网,作者不言,侵删。
在我们的程序(脚本)中使用多个条件时,逻辑或&与操作非常有用。或在两个或多个条件之间使用。如果任何一个条件返回为true,则返回真。与在两个或多个条件之间使用。只有当所有条件都返回为真时,才会返回true。
使用逻辑或
逻辑或在bash脚本中与运算符-o一起使用。下面的shell脚本将展示如何在两个条件之间使用逻辑或(-o)。
1 2 3 4 5 6 7 8 9 | #!/bin/bash
read -p "Enter First Numeric Value: " first
read -p "Enter Second Numeric Value: " second
if [ $ first -le 10-o$ second -gt 20 ]
then
echo "OK"
else
echo "Not OK"
fi
|
使用逻辑与
阅读剩余部分
相关阅读 >>
linux中什么是shell
如何在shell脚本中传递命令行参数
linux运维之shell变量.md
linux中如何运行shell程序
shell--标准输入输出(read&echo)
linux中的shell命令如何使用
freeworld.posterous.com linux bash shell cheat sheet----autho:raphael
adb shell是什么意思
linux中bash是什么意思?
如何在shell脚本中使用逻辑或&和
更多相关阅读请进入《shell》频道 >>
转载请注明出处:木庄网络博客 » 如何在shell脚本中使用逻辑或&和