if...else双分支
1.1、if...else双分支语法

单行表示:

if expression; then statement...; else statement...; fi

多行表示:

if expression; then
    statement...;
else
    statement...;
fi

解释:

expression的运行结果为0,表示

expression的运行结果为非0,表示

1.2、示例
if command -v java &> /dev/null; then echo "JDK is already installed!"; else brew install jdk; fi
if command -v java &> /dev/null; then
    echo "JDK is already installed!";
else
    brew install jdk
fi