Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I know I'm not very close. need some help writing this code for Linux. it is a do-while loop of 99 bottles of beer on

image text in transcribed

image text in transcribed

image text in transcribed

I know I'm not very close. need some help writing this code for Linux. it is a do-while loop of 99 bottles of beer on the wall. thanks

Last time, we used a single variable from the command line in our if-then script. This time, we'll use more than one variable set up at the command line. Note that these variables can be strings or numbers - Linux doesn't care. If you run: samplescript.sh burger fries drink Then, burger would be set to $1, fries to $2, and drink to $3. (The numeral variable names are always sequential.) You could then refer to $1 as a variable in your script, and it would return "burger", while $3 would return "drink. However, samplescript.sh snow rain hail would give $1 as "snow" when the script was run this time. 1. Use a while loop to build another annoying song, "99 Bottles of (Root) Beer on the Wall". If you don't know the song, it goes: 99 bottles of beer on the wall 99 bottles of beer Take one down, pass it around 98 bottles of beer on the wall ...and so on. This time, though, you'll customize it to work for any number of bottles and to do a bunch more things as well using the notes below. Have fun! Notes: Use do-while structure for the main loop. Pause for 1/2 second after each line "sung. Print a blank line after each verse so you know where the break is. Use expr to update the count variable(s). Read the starting number of bottles from the command line. Have the loop run until there are zero bottles of (root) beer left. Embed an if-then loop that will do the following after every 10 (root) beer. o Print "Phew! I need a break..." o Pause for two seconds. o Clear the terminal window. o Pause for two seconds. o Print "OK, that's better.** o Pause for two more seconds, and then return to the loop. o (Hint: You'll want an extra counter variable for this process.) When the final (root) beer has been consumed and there are none left: o Using expr (or some other calculation method), calculate the number of ounces of (root) beer consumed. Assume a 12-oz bottle. Echo that to the screen as part of a sentence. o Echo/print a statement that you would consider appropriate after you and your friends finished consuming those 99 (root) beers. while true; do echo "$1 bottles of beer on the wall" echo "$1 bottles of beer" echo "Take one down, toss it around" 1 echo ""$1-1" bottles of beer on the wall" 2 sleep 2 I 3 clear 14 done

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago