#!/bin/bash file=quiz1.txt # 引数を ANSWER に代入 ANSWER=$1 # i に適当な値を代入するように促す echo "What is your number?" | tee $file read i # quiz1.txt に i を出力する echo $i >> $file # i が ANSWER と一致するまでループを回す until [ $ANSWER = $i ];do # i が ANSWER よりも小さいかどうか判定する if [ $i -lt $ANSWER ] # i が ANSWER よりも小さいことを表す then echo "Your number is smaller than the ANSWER." | tee -a $file # i が ANSWER よりも大きいかどうか判定する else # 画面上に i が ANSWER よりも大きいことを表す echo "Your number is larger than the ANSWER." | tee -a $file fi # 再び i に適当な値を代入する echo "What is your number?" | tee -a $file read i echo $i >> $file done # i と ANSWER が一致したことを表す echo "Your answer is matches the ANSWER!!" | tee -a $file