Script path resolution
Resolve script paths and report their directory and basename.
Understand the pattern
Handling script paths without depending on the current directory helps operators explain what they know before they change anything.
realpath- Resolve a path to its canonical location in the virtual filesystem.
Resolving a path and reading its contents are separate operations.
basename- Remove directory components from a path string.
String manipulation does not verify that the target exists.
dirname- Extract the directory portion of a path string.
A path can be syntactically valid without naming an existing directory.
Worked example and expected result
$ realpath scripts/deploy.sh/home/learner/scripts/deploy.sh
Exit status: 0. The command completed successfully in the training fixture.
$ basename scripts/deploy.shdeploy.sh
Exit status: 0. The command completed successfully in the training fixture.
$ dirname scripts/deploy.sh/scripts
Exit status: 0. The command completed successfully in the training fixture.
Explain it
Apply it elsewhere
Keep the momentum.
Complete the lab, then explain and apply the pattern.
Next: Script change reviewTry an incident drillAnonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.