Is there a way to count how many files/folders exist on the system?

Even better if i could get the list into a csv file?

  • you mean, given a folder, count files inside it? Jun 5, 2012 at 15:19
  • Sorry but I somehow miss the point of this. You are aware that there are virtual file systems like proc and sys are mounted as well? If you want to validate contents of directories use check sums and programs like md5deep.
    – LiveWireBT
    Jun 5, 2012 at 17:31

4 Answers 4


The following command will output how many files and folders are present under / on your system.

 echo `find  / . -type d -print 2> /dev/null | wc -l` directories and `find  / . -type f -print 2> /dev/null | wc -l` files are present on this system.

I don't know if my idea is the most elegant, but it works:

tree / | tail -1 > output

It will take a while until the tree will finish, but you will get a number of directories and a number of files, in your file "output".


Type in a terminal:

cd /    
find -type f | wc -l
  • will this get all paths? So for file /directory/file.filetype it will return /directory as well as /directory/file.filetype?
    – David
    Jun 5, 2012 at 16:55
ls -Rtl / | grep -v ^$ | wc -l 

This will list all the dirs and files on the system.

The another good way to do this is to use find.

find / -type f | wc -l

What list you want to take into CSV file?

  • I would like to import into a csv file a list of all possible paths on the system. so /directory, as well as /directory/file.filetype
    – David
    Jun 5, 2012 at 16:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.