A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
Loops turn a shell one-liner into repeatable automation. `for` is ideal when iterating a known set of words or paths; `while` is a better fit for streams and stateful conditions. In security scripts, loop design affects reliability because input might contain spaces, missing files, transient command failures, or far more records than your first test case.
Functions give repeated logic a name and a scope boundary for local variables, but they do not magically isolate side effects. A function can still change directories, modify shell options, or mutate global variables. Treat function boundaries as contracts: state what comes in, what comes out, and which operations are allowed.
Iterates over matching configuration files and preserves each path as one shell word. The useful habit here is to treat the command output as evidence about one system fact, not as a magical diagnosis.
Never use `for x in $(cat file)` as a general line reader. It performs command substitution and word splitting, which destroys whitespace boundaries. Prefer `while IFS= read -r line` for line-oriented data. That single pattern is worth memorizing because it prevents a class of security-tool parsing bugs.
Defines a focused function and invokes it with one explicit argument. Read the result in context: the same command can be correct yet insufficient if a permission boundary, alternate configuration, or different backend changes what it reports.
Uses Bash brace expansion for a small deterministic sequence. In a production workflow, save the raw result when the observation contributes to a finding. That keeps later analysis honest and makes troubleshooting reproducible.
A practitioner’s checkpoint: compare the observed behavior with the assumption your script is about to make. If the assumption is broader than the evidence, narrow the rule. If the evidence is incomplete, report the uncertainty instead of converting it into a confident finding.
Lab discipline: stay inside the declared course environment, prefer read-only checks for learning exercises, and preserve the original output of security tools before transforming it.
Finish the lesson once you have worked through the material. This awards ★ 35 XP.