#!/bin/bash a=$1 #引数をaとする echo What is your number ? echo What is your number ? > quiz1.txt #"What is your number ?"を表示し、quiz1.txtにも書き込む。 read b echo "$b" >> quiz1.txt #入力した数字をbとして読み込み、quiz1.txtにも書き込む。 while [ $a -ne $b ] #a≠bである限り、do〜doneの部分をくり返して実行する。 do if [ $a -gt $b ] then echo Your number is smaller than the answer. echo Your number is smaller than the answer. >> quiz1.txt #もしa>bならば、”Your number is smaller than the answer."と表示され、quiz1.txtにも書き込む。 else echo Your number is larger than the answer. echo Your number is larger than the answer. >> quiz1.txt #もしa> quiz1.txt #"What is your number ?"を表示し、quiz1.txtにも書き込む。 read b echo "$b" >> quiz1.txt #入力した数字をbとして読み込み、quiz1.txtにも書き込む。 done echo Your number matches the answer ! echo Your number matches the answer ! >> quiz1.txt #"Your number matches the answer !"と表示し、quiz1.txtにも書き込む。