另一种写法

控制流 / 条件语句 / if/else 语句

RANDOM=42
latitude=$(( RANDOM % 181 - 90 ))
#latitude 在 -90 到 90 之间

#整个 if 写在一行里:; 代替换行
if (( latitude == 0 )); then location="Equator"; else \
    location="not at the Equator"; fi

#条件为真时 && 运行下一条命令,为假时 || 运行
(( latitude < 0 )) && hemisphere="Southern" || hemisphere="Northern"

#旧写法:[ ] 是命令 test,数字用 -ge 比较;
#[[ ]] 更新也更安全,在 bash 中应当使用它
if [ "$latitude" -ge 0 ]; then sign="+"; else sign="-"; fi

echo "latitude is $latitude"
echo "location is $location"
echo "hemisphere is $hemisphere"
echo "sign is $sign"