From c03633e460c4c89c9afec041b3a1ee6a2a1a43f0 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 19 May 2016 16:28:18 -0500 Subject: [PATCH] Add Show The Disk Usage For The Current Directory as a unix til --- README.md | 3 +- ...ow-disk-usage-for-the-current-directory.md | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 unix/show-disk-usage-for-the-current-directory.md diff --git a/README.md b/README.md index 2fe4e5a..7cccf0f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_421 TILs and counting..._ +_422 TILs and counting..._ --- @@ -388,6 +388,7 @@ _421 TILs and counting..._ - [Search History](unix/search-history.md) - [Search Man Page Descriptions](unix/search-man-page-descriptions.md) - [Securely Remove Files](unix/securely-remove-files.md) +- [Show Disk Usage For The Current Directory](unix/show-disk-usage-for-the-current-directory.md) - [SSH Escape Sequences](unix/ssh-escape-sequences.md) - [SSH With Port Forwarding](unix/ssh-with-port-forwarding.md) - [Sort In Numerical Order](unix/sort-in-numerical-order.md) diff --git a/unix/show-disk-usage-for-the-current-directory.md b/unix/show-disk-usage-for-the-current-directory.md new file mode 100644 index 0000000..fd9b8a5 --- /dev/null +++ b/unix/show-disk-usage-for-the-current-directory.md @@ -0,0 +1,39 @@ +# Show Disk Usage For The Current Directory + +The `du` utility can be used to show disk usage for a particular directory +or set of directories. When used without any arguments, it will show the +disk usage for the current directory. + +```bash +$ du +80 ./.git/hooks +8 ./.git/info +256 ./.git/logs/refs/heads +... +``` + +with the `-h` command we can see it all in a human-readable format + +```bash +$ du -h + 40K ./.git/hooks +4.0K ./.git/info +128K ./.git/logs/refs/heads +``` + +and to get an even clearer picture we can pipe that through `sort -nr` + +```bash +$ du -h | sort -nr +412K ./vim +352K ./postgres +340K ./.git/logs +216K ./.git/logs/refs +184K ./ruby +156K ./unix +148K ./git +... +``` + +This sorts it numerically in reverse order putting the largest stuff at the +top.