(Solved) : Unix Shell Programming Exercise Required Make Copy Following Script File Named Guesssh Bin Q35603086
UNIX Shell Programming
For this exercise you are required to make a copy of thefollowing script into a file namedguess.sh:
echo “guess the number”
set answer = $<
set goal= `tr -dc A-Za-z0-9 </dev/urandom | od -d | head -c 10 | tr -d 0 | tr -d ‘ ‘`
set count = 1
while ($answer != $goal )
if ($answer <$goal ) then
echo “too small”
echo “too large”
@ count ++
set answer =$<
echo “using $count rounds”
- Study the script and be sure to understand it. Review theslides about Shell Overview and Shell Programming with thedescription of what it does. Your task is to incorporatecomments in different parts of the script to explain what itdoes.
- Execute the script and correct any error it may have torun it. You will have to change permissions to the shellscript file to make it executable (remember the chmodcommand).
- You are required to modify the script, make a copy with thename guess_game.sh and implement thefollowing changes:
- Create a main menu, so when you execute the script the userwill have two options (try the command clear to clean thescreen):
1.Run the guessing game
- When the user selects run the game, the game will do the samething with an addition. It should now keep a record of eachscore.
- When finishing the game, the script returns to the main menu,so the user can play again
- When the user selects Exit, the script before ending will printout to the screen the different scores for each game that wasplayed:
Exiting the guessing game
Your average of rounds is:calculated average
Your scores are:
- See if using the exit status of a command may be ofany help.