Count Number of Files and Folders in a Directory Using Terminal

I Googled so much and can’t find any simpler method to count files or folders in a directory in Linux. I am using Ubuntu 14.04. If it’s only files and folders, it would be simple.

Count Files and Folders

$ ls -l | wc -l

The wc -l command is read “WordCount lines”. It means after you executed the ls, the corresponding result will be counted by it’s line. For example, if you are using ls in your working directory, say there are 2 files and 2 folders, it will return 4 lines. If you add it becomes ls -a, it will return 2 more lines. So, it returns 6 lines because of “.” and “..” are counted.

Continue reading Count Number of Files and Folders in a Directory Using Terminal