I need to check the used space in some folders, and I need it to be fast to check because it will be inside a script.
Which command should I use, "du -h" or "df -h"??
Well, they don't do the same thing, so it's a fairly easy choice! df
reports file-system usage. du
reports usage for directories.
You want du
as it gives you the space used by specific files and/or folder(s). df
is used for checking the space used on entire filesystems.
Clearly the answer is du, as the prior respondents stated. If you want to specify the exact directories you're interested in and only want a summary for each then you would use:
du -hs /path/to/dir1
du -hs /path/to/dir2
etc
df
reports on file systems, du
measures directory contents.
Based on your requirements, use: du -h
du
can be sped up; it depends on the directory tree you're trying to check. Depending on what your actual requirements are, doing a find
for files larger than a specific size may be more appropriate?
Aug 29, 2011 at 11:19