Mission 259

Path helper script review

Use basename and dirname as script building blocks.

Shell scripting
8 minutes Admin Lesson 259 of 360
basenamedirnameprintf
Lesson 259 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.

Get web filename

Run basename /srv/www/index.html.

basename /srv/www/index.html
Get web directory

Run dirname /srv/www/index.html.

dirname /srv/www/index.html
Use basename through xargs

Run printf /srv/www/index.html | xargs basename.

printf /srv/www/index.html | xargs basename
Lesson support

What to notice while you play.

Objective

Use basename and dirname as script building blocks.

Hint

Run the commands in order and compare the outputs.

Why it matters

Junior operators build confidence by gathering evidence before changing systems.

Common mistakes
  • Skipping the inspection step.
  • Assuming one command tells the whole story.
Reference

Commands in this lesson.

printf <text>

Print formatted training text.

basename|dirname <path>

Split paths into file and directory parts.