我是bash新手,我一直在try 否定以下命令:
wget -q --tries=10 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
echo "Sorry you are Offline"
exit 1
如果连接到internet,则此if条件返回true.我希望它以另一种方式发生,但把!
放在任何地方似乎都不起作用.
我是bash新手,我一直在try 否定以下命令:
wget -q --tries=10 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
echo "Sorry you are Offline"
exit 1
如果连接到internet,则此if条件返回true.我希望它以另一种方式发生,但把!
放在任何地方似乎都不起作用.
你可以 Select :
if [[ $? -ne 0 ]]; then # -ne: not equal
if ! [[ $? -eq 0 ]]; then # -eq: equal
if [[ ! $? -eq 0 ]]; then
!
分别反转以下表达式的返回.