Open in TheBrain

Practice Lab 10.18

Practice Lab 10.18 — Full for Loop Construction Lab

Name: Date:

Instructions

Complete this entire lab in the assigned Bash environment. Write the scripts in vi. Trace each list and record output and reasoning before/after execution.

  1. Write a four-fruit loop with one sentence per value; save, check file/mode, run.
  2. Write a three-name loop that prints the current name; verify mode and output.
  3. Write a number-word loop for one to five and explain why words alone do not form arithmetic counting.
  4. Construct the Mets/Yankees/Braves/Astros output program; identify every keyword and substitution.
  5. Construct the loop that runs who, ls, pwd; record results and which vary.
  6. Extend a custom list with a value containing punctuation or a different case; predict shell word-list behavior and check with instructor guidance before using spaces in an item. Record what changed.
  7. Compare iteration count and output when list contains unique values, a duplicate, and reordered values.
  8. Explain how to trace a loop without running it; record how files were saved and executed.

Reflection: What must be quoted or otherwise handled carefully if a list item contains spaces?