#!/bin/bash
show_week()
{
echo -n "what you input is:"
echo "$1"
case $1 in
0)
echo "Today is Sunday."
return 0;;
1)
echo "Today is Monday ."
return 0;;
2)
echo "Today is Tuesday."
return 0;;
3)
echo "Today is Wednesday."
return 0;;
4)
echo "Today is Thursday."
return 0;;
5)
echo "Today is Firday."
return 0;;
6)
echo "Today is Saturday."
return 0;;
*)
return 1;;
esac
}
if show_week "$1"
then
echo "What you input is right"
else
echo "what you input is wrong."
fi
exit 0
结果:
~/Note/test # ./30show_week.sh
what you input is:
what you input is wrong.
~/Note/test # ./30show_week.sh 1
what you input is:1
Today is Monday .
What you input is right
~/Note/test # ./30show_week.sh 3
what you input is:3
Today is Wednesday.
What you input is right
~/Note/test # ./30show_week.sh 5
what you input is:5
Today is Firday.
What you input is right
~/Note/test # ./30show_week.sh 13
what you input is:13
what you input is wrong.