Files
notes_estom/Linux/shell/test07.sh
法然 dd11a44b1f shell
2022-10-03 00:08:52 +08:00

23 lines
382 B
Bash

#!/bin/bash
PRICE=$( expr $RANDOM % 10)
TIMES=0
echo "猜测商品的价格0-9"
while true
do
read -p "请输入猜测的价格:" YOURS
let TIMES++
if [ $YOURS -eq $PRICE ]
then
echo "right after $TIMES times"
exit 0
elif [ $YOURS -gt $PRICE ]
then
echo "bigger than price"
else
echo "smaller than price"
fi
done