How to find the total number of files in a folder on Linux?
By default, you can use
ls command to sort the names, which can take a while if there are a lot of files exiting in the directory. Also, there will be no output until all of the names are read and sorted. To get the fast output, use the
ls -f option to turn off sorting.
ls -f | wc -l
Note: This will also enable
.., and other files starting with
. will be counted.