[内容] Linux case 条件判断

内容一:case 语句的格式

case <variable> in
<variable value 1>)
<the command to execute when the variable is this value>;;
<variable value 2>)
<the command to execute when the variable is this value>;;
<variable value 3>)
<the command to execute when the variable is this value>;;
*)
<the command to execute when the variable value is other>;;
esca

内容二:case 语句的使用案例

#!/bin/bash

read -p "Which one do you like better, eternalcenter eternalcentre ec-x : " name

case $name in
eternalcenter)
echo "Do you realy like $name better? eternalcenter?" ;;
eternalcentre)
echo "Do you realy like $name better? eternalcentre?" ;;
ec-x)
echo "Do you realy like $name better? ec-x?" ;;
*)
echo "So you don't like them all ." ;;
esac