How to count all files inside a folder, its subfolder and all . The count should not include folder count

LinuxCommand Line

Linux Problem Overview


How to count all files inside a folder, its subfolder and all . The count should not include folder count.

I want to do it in MAC

Linux Solutions


Solution 1 - Linux

find . -type f | wc -l will recursively list all the files (-type f restricts to only files) in the current directory (replace . with your path). The output of this is piped into wc -l which will count the number of lines.

Solution 2 - Linux

Find all files under myfolder and count them using wc. This works on linux:

find myfolder -type f | wc -l

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPeterView Question on Stackoverflow
Solution 1 - LinuxJeff FosterView Answer on Stackoverflow
Solution 2 - LinuxperrealView Answer on Stackoverflow