Open in TheBrain

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.

  1. Create a user-controlled repeat loop using carryon=Y; test at least two continuation inputs and one stopping input.
  2. Create a counter while loop from 0 to 10. Explain the six structural lines and trace values.
  3. Rewrite as until to count through 25. Explain the logical difference.
  4. Write a weekday guessing loop from date +%a; describe the date variable, prompt/read, comparison, and repeat behavior.
  5. Explain a loop with echo before increment, using a small boundary to show output order.
  6. Write count-by-two to 20, countdown 100 to 0, and multiply-by-three through 243. Identify initialization, condition, update, output position.
  7. Test and record outputs; if actual output differs from prediction, explain boundary or update.
  8. Compare sentinel, counter, and sequence loops.

Reflection: Which loop’s stopping condition was hardest to formulate?