【使用例紹介】if文【シェルスクリプト】

雑学

備忘録になります。

# cat wrk.sh
echo -n "Please Input Param: "
read AAA

if [ "$AAA" = "red" ] ; then
    echo "Apple"
elif [ "$AAA" = "green" ] ; then
    echo "Leaf"
elif [ "$AAA" = "blue" ] ; then
    echo "Water"
else
    echo "Hello!"
fi

# ./wrk.sh
Please Input Param: red
Apple
# ./wrk.sh
Please Input Param: green
Leaf
# ./wrk.sh
Please Input Param: blue
Water
# ./wrk.sh
Please Input Param: aaa
Hello!

関連リンク