Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Human-readable sizes all over the place' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Human-readable sizes all over the place
Authored by: frankxiv on Aug 04, '04 04:11:28PM

This is nice if all you want to know is the size of the individual files. Does anyone know of a unix command that will give you the total size of a directory (and all of its contents)?

Frank



[ Reply to This | # ]
Human-readable sizes all over the place
Authored by: dr_bob_cms on Aug 04, '04 04:45:58PM

du does exactly that. man du



[ Reply to This | # ]
Human-readable sizes all over the place
Authored by: frankxiv on Aug 06, '04 09:12:59AM

Thanks!



[ Reply to This | # ]
Human-readable sizes all over the place
Authored by: cubal on Aug 04, '04 04:49:53PM
du -sh "dirname" (s for summary, h for human-readable) will give you what you're after.

[ Reply to This | # ]
Human-readable sizes all over the place
Authored by: frankxiv on Aug 06, '04 09:19:13AM

Thanks! du -sh "directory name" did indeed give me the total size of a directory.

Also, for those interested du -ah gives you the size of every file inside of the directory (and in the directories inside of that directory). In other words, it will recursively list all files inside of a directory (including other directories) along with the size of each. That is exactly the command I was looking for.

Thanks everyone!

Frank



[ Reply to This | # ]
Human-readable sizes all over the place
Authored by: xor on Aug 10, '04 07:24:05PM
 du -h some_dir_name | tail -1


[ Reply to This | # ]
Human-readable sizes all over the place
Authored by: ogs on Aug 11, '04 12:09:03PM

One I use quite frequently is

du -d1 -h

where -d[num] is the depth that you want to show

du -d1 | sort -n

is handy too



[ Reply to This | # ]