没啥好写的,直接上代码把
如题:例如:超市卖水果
#!/bin/bash
read –p “请输入你要查询的商品: ”var
case $var in
apple)
echo “apple 1.4元每斤”
;;
orange)
echo “orage 1.5元每斤”
;;
banana)
echo “banana 1.6元每斤”
::
esac
效果图
shell代码:
#!/bin/bash
echo “===================================”
echo “=============1.apple =="
echo "=2.banana"
echo "=3.orange"
echo "=4.exit "
echo "=”
while true
do
read -p “请按菜单输入[1~4]:” num
if [ $num -eq 1 ]
then
echo “apple is 1/kg”
elif [ $num -eq 2 ]
then
echo “banana is 2/kg”
elif [ $num -eq 3 ]
then
echo “orange is 3/kg”
elif [ $num -eq 4 ]
then
echo “欢迎下次光临”
exit
fi
done