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.
- Write/run a loop over fruit values, printing each within a sentence.
- Write/run a name loop that prints three names. Explain why output is one line per list item.
- Write/run a loop over number words one through five; explain why its variable is not being incremented arithmetically.
- Construct the Mets/Yankees/Braves/Astros loop output and mark the loop keywords.
- Construct a loop invoking
who,ls,pwd; explain output differences between repeated runs. - Create loops with four, five, and two list values. Record body executions and compare with list sizes.
- Create reordered list of the same values and compare output sequence.
- 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?