Practice Lab 10.19
Practice Lab 10.19 — for Loops: Data and Command Lists
Name: Date:
Instructions
Use Bash scripts in a disposable directory and the course vi workflow. Record code, permissions, predictions, output, and explanations.
- Create
fruits, iterating over four fruit values and printing a message per item. Save and run after verifying the file. - Create
namelistover three names; print each and check permissions. - Use number words one through five in a message loop; explain the counter question.
- Write the required four-team sentence loop, marking keywords and changing value.
- Write a command loop for
who,ls,pwd; record output and describe what each command reports. - Create a second command list with two safe inspection commands available in your lab; explain why the loop body must invoke each list value. Do not include destructive commands.
- For each loop, count list elements, predict body runs, and compare actual runs. Try a duplicate and reordered list.
- Explain script save, mode verification, invocation, and output interpretation.
Reflection: Why is practicing with safe inspection commands important when the loop executes commands?