How can we count the number of files and folders in a deep Linux directory and list them by folder name. For e.g.

         |__fileA, fileB, etc
         |_ SubSubFolder1
         |__fileA, fileB, etc
         |_ SubSubFolder1

Should give result like:

MainFolder: 2 Folders, n files (all files in the directory)
MainFolder/SubFolder1: 1 Folder, m files
New contributor
Prakhar Kaushik is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Prakhar Kaushik is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.