Practice Lab 10.3
Practice Lab 10.3 — Complete Bash for Loop Lab
Name: Date:
Instructions
Work in a practice directory using the assigned shell. Type scripts in vi, save, verify, and run. Trace values first; record output and explain keywords.
- Write
fruitsloop overapples pears oranges mangoes, printing a descriptive message for each. Verify filename/mode and run. - Write
namelistloop over three different first names and echo each. Save, set executable mode as requested, verify and run. - Loop over words
one two three four five, include the current value in output. Explain “counter” versus list iteration. - Create the baseball-team sentence loop for Mets, Yankees, Braves, Astros. Underline/identify
for, variable,in, list,do, body,done. - Build command loop running
who,ls,pwd; invoke loop value as a command, record real output. - For each script, predict iteration count and output order. Add one extra list value to one script and explain the effect.
- Describe how you save, verify, set permissions, and run each script; note differences between sourcing and executing if relevant.
Reflection: Which command-loop output changed because of system state rather than loop syntax?