Practice Lab 10.13
Practice Lab 10.13 — Bash for Loops: Full Practice
Name: Date:
Instructions
Complete each task as a whole worksheet. Use Bash, vi, and an assigned practice folder. Predict before running, record code and results, and explain the loop’s behavior.
- Create a fruit script using
for,in,do,done; print one message for each of four list items. Save, inspect, set mode, run. - Create a
namelistscript over three names; print each, check mode and run. - Iterate over number words and explain why this is list traversal rather than numeric increment.
- Write the four-team sentence loop and identify all keywords and changing value.
- Write and execute the command loop for
who,ls,pwd. Explain why some output is environmental. - Add duplicate, reorder, and extend list values in separate tests. Predict count/order, execute, compare.
- Trace loop variable and body effect in a table for one script.
- Explain how script creation, permissions, and invocation work together; identify the script’s command and loop components.
Reflection: How do duplicates in a list affect the number of iterations?