Sign inSign up free

758. A Count That Wraps at 256

medium 20 XP ~8 minHands-on lab

/home/student/bin/inventory.sh DIR reports how many .log files and how many .gz files a folder has. On the harbor log server it printed:

logs: 44
archives: 3

but ls shows hundreds of log files. Small test folders look right.

Task

Fix inventory.sh so it prints the correct counts for any number of files. Keep the output format and keep the count_ext function (callers in other scripts use it): it must print the number, which callers capture with $(count_ext DIR EXT).

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Shell Scripting for Automation. Next step: Split Paths Without Calling basename

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.