Open in TheBrain

Practice Lab 10.12

Practice Lab 10.12 — Full Bash Loop Practice

Name: Date:

Instructions

Use the course shell and vi editor. In every case trace the list before running, then record output. Keep all scripts disposable and check permissions and path.

  1. Write/run a loop over fruit values, printing each within a sentence.
  2. Write/run a name loop that prints three names. Explain why output is one line per list item.
  3. Write/run a loop over number words one through five; explain why its variable is not being incremented arithmetically.
  4. Construct the Mets/Yankees/Braves/Astros loop output and mark the loop keywords.
  5. Construct a loop invoking who, ls, pwd; explain output differences between repeated runs.
  6. Create loops with four, five, and two list values. Record body executions and compare with list sizes.
  7. Create reordered list of the same values and compare output sequence.
  8. Explain loop variable assignment, body repetition, save/permissions/run workflow, and how to predict iteration count.

Reflection: What is the relationship between the in list and the loop variable’s value on each pass?