I want to find the total count of the number of files under a folder and all its sub folders.
Maybe something like this will do the trick:
find . -type f | wc -l
Try the command from the parent folder.
find . -name <pattern> -type ffinds all
files in the current folder (
.) and its subfolders.
-name <pattern>only looks for certain files that match the specified pattern. The match is case-sensitive. If you need the match to be case-insensitive, use
- The result (a list of files found) is passed (
wc -lwhich counts the number of
The fastest and easiest way, is to use
tree. Its speed is limited by your output terminal, so if you pipe the result to
tail -1, you'll get immediate result. You can also control to what directory level you like the results, using the
-L option. For colorized output, use
-C. For example:
$ tree share/some/directory/ | tail -1 558 directories, 853 files $ tree -L 2 share/some/directory/ | tail -1 120 directories, 3 files
If it's not already there, you can get it here.