Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
you mean, given a folder, count files inside it? –  Juan Sebastian Totero Jun 5 '12 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 '12 at 17:31
add comment

4 Answers

I don't know if my ideea 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"]

share|improve this answer
add comment

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.
share|improve this answer
add comment

Type in a terminal:

cd /    
find -type f | wc -l
share|improve this answer
    
will this get all paths? So for file /directory/file.filetype it will return /directory as well as /directory/file.filetype? –  David Jun 5 '12 at 16:55
add comment
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?

share|improve this answer
    
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 '12 at 16:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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