The Computer Oracle

How do I find the size of a directory on a Unix-like command-line?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow

--

Chapters
00:00 How Do I Find The Size Of A Directory On A Unix-Like Command-Line?
00:14 Accepted Answer Score 46
00:31 Answer 2 Score 0
00:54 Thank you

--

Full question
https://superuser.com/questions/399240/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#commandline #unix

#avk47



ACCEPTED ANSWER

Score 46


du -s directory, as in "disk usage, sum"

Use du -sk to show the size in kilobytes (default is to show number of 512-byte blocks), or du -sh for a more human-friendly output. For more options, type man du.




ANSWER 2

Score 0


This is the same as -s, but replace 0 with 1 and you can get just the content in the folder:

du -h -d 0 /path/to/file

If you want the whole volume, you should use df instead of du (path is optional):

df -H /

Off-topic: One (very) spooky thing: I happend to be just a street away from Arne Stenström.

/Robert