Mission 349

Script path resolution

Resolve script paths and report their directory and basename.

Shell scripting
8 minutes Admin Lesson 349 of 360
realpathbasenamedirname
Lesson 349 of 360 0/360 lessons 0/17 missions Shell scripting · 8 minutes
0%
Continue View profile
Ops lab terminal Training lab
New learnerrank 0XP 0%complete
learner@clairos:/home/learner $ Unix ops lab: type a command, press Enter
Instructions 8 minutes

Click any instruction for the command details, the why, and the common mistake to avoid.

Resolve the script path

Run realpath scripts/deploy.sh.

realpath scripts/deploy.sh
Print the script name

Run basename scripts/deploy.sh.

basename scripts/deploy.sh
Print the script directory

Run dirname scripts/deploy.sh.

dirname scripts/deploy.sh
Lesson support

What to notice while you play.

Objective

Build repeatable confidence with handling script paths without depending on the current directory.

Hint

Start with realpath scripts/deploy.sh, inspect the result, then continue in order.

Why it matters

Handling script paths without depending on the current directory helps operators explain what they know before they change anything.

Common mistakes
  • Skipping the output that proves handling script paths without depending on the current directory.
  • Changing several things before recording a baseline.
Reference

Commands in this lesson.

realpath <path>

Resolve a path to its canonical simulated location.

basename|dirname <path>

Split paths into file and directory parts.