
Today, I am back to give you a quick tip on how to count the Total Number of Files in a Directory (as well as sub-directories underneath it).
Very simply, I am going to split into 2 parts. Firstly, to count the number of files in a particular directory. Secondly to count the total number of files in a directory and including all the sub-directories underneath it, using Linux command line.
Part 1: File Count in a Directory
Type the following in the command line:
ls | wc -l
In the above command, you may need to deduct 2, because of the "." and ".." that are included in the count. But naturally, that gives you what you need.
Part 2: File Count in a Directory and Sub-directory
This is probably more useful, if you want to know the total number of files underneath the root.
find . type -f | wc -l
Very short command line, but it gives you the icing.
Post new comment