shell-5:case比if(elif else)方便
# cat case.sh#!/bin/bash
read -p "tap a num to echo:" num
case $num in
1)
echo 1 ;;
2)
echo 2 ;;
3)
echo 3 ;;
*)
echo "other num" ;;
esac
# sh case.sh
tap a num to echo:1
1
# sh case.sh
tap a num to echo:4
other num
#
页:
[1]