简单的shell脚本
#!/bin/bash
PRICE=$(exrp $RANDOM % 1000)
t=0
echo “商品价格为0-999之间,猜猜看”
while true
do
read -p "请输入您猜测的价格: " I
let t++
if [ $I -eq $PRICE ] ; then
echo “恭喜你猜对了,实际价格是 $PRICE”
echo "您总共猜测了 $t 次 “
exit 0
elif [ $I -gt $PRUCE ] ; then
echo “太高了”
else
echo “太低了”
fi
done
#!/bin/bash
for NO in cat no
do
while true
do
read -p "Are you sure [Y/N]: " m
if [ $m = $NO ]
then
echo "结束 "
exit 0
elif [ $m = yes ]
then
echo “请继续”
else
echo “您重新输入”
fi
done
done
#!/bin/bash
read -p “请输入一个字符,并按ENTER确认: ” KEY
case “$KEY” in
[a-z] | [A-Z])
echo “你输入的是字母。 “
;;
[0-9])
echo “你输入的是数字。 “
;;
*)
echo “你输入的是空格、功能键、或其他字符。“
esac