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.
- Write a four-fruit loop with one sentence per value; save, check file/mode, run.
- Write a three-name loop that prints the current name; verify mode and output.
- Write a number-word loop for one to five and explain why words alone do not form arithmetic counting.
- Construct the Mets/Yankees/Braves/Astros output program; identify every keyword and substitution.
- Construct the loop that runs
who,ls,pwd; record results and which vary. - 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.
- Compare iteration count and output when list contains unique values, a duplicate, and reordered values.
- 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?