Linux – How to find the number of files in a folder?

bash arguments, pass parameter, pass argument to script

This seems like a pretty simple piece of information to ask for, but then why is there no intuitive way for Linux novices to accomplish this? In Windows command-line, the output of the dir command includes the number of files and the number of folders in the current directory. Well, here are some ways you can do it in Linux…

Find the number of files in the current and all sub-directories

find . -type f | wc -l

Find the number of files in the current directory

find . -maxdepth 1 -type f | wc -l

See also  3 Ways How to 'Sleep' in a Linux Bash Shell Script

Leave a Comment