Practice Lab 10.4
Practice Lab 10.4 — for Loops: Lists, Output, Commands
Name: Date:
Instructions
Use Bash and the vi editor as directed. Complete the entire worksheet, recording predictions, commands, output, and explanations. Keep scripts in a disposable practice folder.
- Build and run
fruits: iterate over four fruit values and print a sentence for each. Record the list, variable, body, and output. - Build
namelist: loop over three names and print each. Set mode as assigned and verify withls -lbefore running. - Build a word-list loop using
one two three four five. Explain whether it is a numeric counter and why. - Write the loop that prints the requested baseball-team sentence for Mets, Yankees, Braves, Astros; identify each syntax keyword.
- Write a loop that executes
who,ls,pwd. Predict each result type, then run and explain variable output. - Compare iteration counts in all loops. Add/remove one item from a list and record how output changes.
- Explain vi save/exit, permission adjustment, verification, and script invocation used.
Reflection: What part of the for syntax separates the item list from the repeated body?