文件分類 [總覽]
社群資訊
大概像這樣寫~ ( 利用Shell 完成 --終極密碼)
(艾鍗學院, service@ittraining.com.tw, 2013-06-10 17:50)
1樓
#!/bin/sh
secret=50 #default
guess=1
min=1
max=100
read -p " set a secret (1-100):" secret
echo "Start game................."
read -p "guess a value $min-$max:" guess
while [ $guess -ne $secret ]; do
if [ $guess -gt $secret ] ; then
max=$guess
else
min=$guess
fi
read -p "guess a value again $min-$max:" guess
done
echo "\33[31m"
echo "Yes!You Got Answer!"
echo "\33[0m"