Any fast way to know the total file size under a folder
I know that du command and give me the answer.
But, it is too slow for my usage because I need to check the folders which contains more than 1G of files. Do any command that can give me the folder size instantly? |
du -h gives it in human readable form in a nanosecond on my machine
|
Try:
--- du -h /home/<username>/ That will isolate it to that directory only. JN |
Instantly is impossible. What du does is it stats the files to check their file size. Since you have a large number of files (I'm assuming), it's going to take a while to do that. Since you want this done, it has to be done either while you're paying attention or not. You could set up, for example, a cron job that checks the filesizes while you are busy doing other things and reports all of that info to a file called "Filesizes" under each filesystem (this is what we do at work), but the time is going to be spent either when you run du by hand or when it's run in the cron job. If you run a cron job, you can then just look in the Filesizes file to find what you need.
|
Quote:
|
du -hs
?? It may be a little faster cause it don't have to display all the filenames. |
another option, if you just want a single directory (not recursive), is
ls -hs | head -1 |
I tried to compare this stuff between Windows and Linux.
In my Windows system, I have about 35000 files. It can give me the total filesize in about 15 seconds (right click all folders and click the Properties) However, in Linux, for using "du -s", it takes more than 1 minutes to count only 7500 files. Why is it so slow? Actually, I only need a total, is there any faster way? Well, instantly is impossible. But 15 seconds is better than 1 minute. |
Quote:
|
Is everything in one filesystem tree (i.e., does everything show up under one mount point)? If so, df -h /mountpoint will profide you with a reasonable facimile of what you want (as Chinaman meant to say).
What filesystem are you using for this (mostly out of curiosity). Here's a faster way (in the root of the directory you wish to get the sum of all file sizes): Code:
find . -printf %k"\n" | awk '{ sum += $1 } END { print sum }' If you read the man pages, you could do some pretty cool stuff with this. . . |
It may be faster because it doesn't have to print out a long list of files
|
Code:
du -sh /path |
I have tried the commmnad
Code:
find . -printf %k"\n" | awk '{ sum += $1 } END { print sum }' After some investigation, I found out that they main point is in the "updatedb" process. Actually, every linux (i mean Redhat) will run the updatedb after bootup. The updatedb will call the slocate which indexes the files so that searching of files is faster. Yes, I fuond that the if this updatedb is being run (or du is run before), there will be an index database created. Thus, after that, every file searching or counting is very fast. However, I have another issues that I needed to stop this updatedb process. Furthermore, for my requirment, everytime after reboot, I needed to get the folder size(not the whole filesystem, but only a subfolder that contains a lot of files). As a result, I still need to wait for a long time(about 2 mins) to count the folder size....... Any help??? |
Well , I tried to use what I learned in this thread , but I appear to be a little dense , it seems ;
How do you [i]exclude[/u] directories from it? IE.- I want to know how much space is used on my mainpartition , but I have four other partitions mounted there as well : /hda8 , /hda9 / hda10 and hdc1. I want these to be left out of the search. I tried both the -x and the -X parameter but somehow I manage to get the syntax all wrong. |
have you tried KDiskFree? it is a gui app on kde that shows partitions and mount points and how much space is on each one and how much is free.
|
All times are GMT -5. The time now is 09:30 PM. |