CodeVideoNote
中文Workspace

Shell · Original teaching example

Shell: count matching files

This teaching case was authored to show a note format. It was not extracted from a real video or user note, and it has no invented timestamps.

Problem

Count .log files below a chosen directory, including nested folders.

Approach and limits

Use find to select regular files by name, then count the resulting lines. Check unusual file names separately if your shell pipeline must handle them.

Example code

find ./logs -type f -name "*.log" | wc -l

Check it yourself

Create two .log files and one .txt file in a temporary test directory; the result should be 2.