6/15

Count Matching Files Recursively

easy 10 XP ~7 minHands-on lab

The monitoring team wants a tiny helper they can point at any directory.

Task

Create the executable script /home/student/bin/count-files.sh that takes one argument, a directory, and:

  • prints only a number: how many regular files whose name ends in .out exist anywhere under that directory (subdirectories included)
  • counts files with spaces or newlines in their names correctly, and ignores directories named *.out
  • if the argument is not an existing directory, prints not a directory: <arg> to stderr and exits with code 1

The grader runs it against hidden directory trees.

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.

TerminalNot started

Your machine is ready to start

Create a free account to open a machine and get graded.