Open in TheBrain

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.

  1. Create a fruit script using for, in, do, done; print one message for each of four list items. Save, inspect, set mode, run.
  2. Create a namelist script over three names; print each, check mode and run.
  3. Iterate over number words and explain why this is list traversal rather than numeric increment.
  4. Write the four-team sentence loop and identify all keywords and changing value.
  5. Write and execute the command loop for who, ls, pwd. Explain why some output is environmental.
  6. Add duplicate, reorder, and extend list values in separate tests. Predict count/order, execute, compare.
  7. Trace loop variable and body effect in a table for one script.
  8. 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?