Practice Lab 11.8
Practice Lab 11.8 — Complete Bash Loop Design
Name: Date:
Instructions
Complete all loop examples in Bash. Record exact commands, trace values, output, and explanations. Use the assigned environment and verify each loop terminates.
- Create a user-controlled repeat loop using
carryon=Y; test at least two continuation inputs and one stopping input. - Create a counter
whileloop from 0 to 10. Explain the six structural lines and trace values. - Rewrite as
untilto count through 25. Explain the logical difference. - Write a weekday guessing loop from
date +%a; describe the date variable, prompt/read, comparison, and repeat behavior. - Explain a loop with
echobefore increment, using a small boundary to show output order. - Write count-by-two to 20, countdown 100 to 0, and multiply-by-three through 243. Identify initialization, condition, update, output position.
- Test and record outputs; if actual output differs from prediction, explain boundary or update.
- Compare sentinel, counter, and sequence loops.
Reflection: Which loop’s stopping condition was hardest to formulate?