Open in TheBrain

Practice Lab 10.17

Practice Lab 10.17 — List Order, Repetition, and Commands

Name: Date:

Instructions

Use Bash, vi, and disposable scripts. Record predictions, exact code, actual output, and explanations. Check mode before running as directed.

  1. Create and run a fruit loop; print a sentence for each of four values. Explain each iteration.
  2. Create and run a name loop over three names; inspect permissions and explain how you invoked it.
  3. Make a loop over number words one through five. Explain whether it is a numeric counter.
  4. Write the required baseball-team output loop; label for, variable, in, list, do, body, done.
  5. Write a loop that executes who, ls, pwd; explain what depends on the host system/current directory.
  6. Reorder one list without changing its items; predict and observe output order. Then add one value and compare iteration count.
  7. Include a short trace table: pass number, loop variable, body output/command.
  8. Explain how script saving, permissions, and loop invocation fit together.

Reflection: What changed when you reordered the list, and what stayed constant?