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