Practice Lab 10.2
Practice Lab 10.2 — Full List-Driven Loop Worksheet
Name: Date:
Instructions
Complete all tasks in Bash; use vi and the instructor’s workflow. Record code, prediction, output, and explanation. Check each script’s location and permissions before executing.
- Create
fruitslooping throughapples pears oranges mangoes; print a sentence per item. Save, set permissions as directed, verify, run. - Create
namelistlooping overAva Ben Chen; print one name each time. Save, set executable mode as required, verify and run. - Create a loop over
one two three four fivewith a message containing the current list value. Explain why numeric words do not automatically count arithmetically. - Write a team loop producing required sentences for Mets, Yankees, Braves, Astros. Identify loop variable/list/body/keywords.
- Write a command loop to execute
who,ls, andpwd; record outputs and explain system-dependent differences. - Predict the iteration count for each loop from list size. Change one list by adding a value and predict/run again.
- Explain saving in vi, permission checking, and the
. filenameinvocation specified by class; distinguish from Bash invocation if taught.
Reflection: How did changing a list affect loop behavior?