官术网_书友最值得收藏!

Nested if statements

If a single level of if statements is not enough and you would like to have additional logic within an if statement, you can create nested conditional statements. This can be done in the following way:

#!/bin/bash
USER_AGE=18
AGE_LIMIT=18
NAME="Bob" # Change to your username if you want to execute the nested logic
HAS_NIGHTMARES="true"

if [ "${USER}" == "${NAME}" ]; then
if [ ${USER_AGE} -ge ${AGE_LIMIT} ]; then
if [ "${HAS_NIGHTMARES}" == "true" ]; then
echo "${USER} gets nightmares, and should not see the movie"
fi
fi
else
echo "Who is this?"
fi
主站蜘蛛池模板: 南宁市| 新蔡县| 胶南市| 洛隆县| 伊吾县| 辽阳县| 临猗县| 上饶县| 美姑县| 五常市| 溧水县| 天台县| 无为县| 新安县| 松阳县| 闽侯县| 于田县| 平顶山市| 怀集县| 双牌县| 象山县| 桃园县| 清远市| 牙克石市| 白河县| 桃江县| 河津市| 合江县| 阿合奇县| 胶州市| 南部县| 藁城市| 萍乡市| 赤峰市| 肥城市| 于田县| 禄丰县| 尚志市| 靖安县| 信丰县| 灵宝市|