{"id":886,"date":"2013-08-18T12:46:17","date_gmt":"2013-08-18T12:46:17","guid":{"rendered":"http:\/\/www.nooblet.org\/blog\/?p=886"},"modified":"2013-08-18T12:46:17","modified_gmt":"2013-08-18T12:46:17","slug":"quick-disk-usage-bash-script","status":"publish","type":"post","link":"https:\/\/www.nooblet.org\/blog\/2013\/quick-disk-usage-bash-script\/","title":{"rendered":"Quick Disk Usage Bash Script"},"content":{"rendered":"<p>The command, <a href=\"https:\/\/www.gnu.org\/software\/coreutils\/manual\/html_node\/du-invocation.html\">du (estimate file space usage)<\/a> is a core Linux program I use often.<\/p>\n<p>When trying to find where space is being used on a disk I run the following command:<\/p>\n<blockquote><p><code>du --max-depth=1 -xh<\/code><\/p><\/blockquote>\n<p>This produces a list of all directories with their total size in human readable format. However it isn&#8217;t sorted, and it doesn&#8217;t tell me how much is being used in the current directory.<\/p>\n<p>So I wrote a script which lists the directory sizes in human readable format, sorts them by size, and also has a seperate entry for the current directory, along with total.<\/p>\n<p>Typical output:<\/p>\n<blockquote><p><code>$ ddu<br \/>\n0K      .\/proc<br \/>\n0K      .\/run<br \/>\n0K      .\/sys<br \/>\n4K      [.]<br \/>\n4K      .\/boot<br \/>\n4K      .\/data<br \/>\n4K      .\/dev<br \/>\n4K      .\/lib64<br \/>\n4K      .\/media<br \/>\n4K      .\/mnt<br \/>\n4K      .\/opt<br \/>\n4K      .\/selinux<br \/>\n4K      .\/tmp<br \/>\n12K     .\/srv<br \/>\n32K     .\/home<br \/>\n76K     .\/root<br \/>\n5.5M    .\/sbin<br \/>\n5.5M    .\/bin<br \/>\n5.7M    .\/etc<br \/>\n12M     .\/lib<br \/>\n341M    .\/var<br \/>\n761M    .\/usr<br \/>\n--<br \/>\n1.1G    [total]<\/code><\/p><\/blockquote>\n<p>&nbsp;<br \/>\n<b>Download<\/b><br \/>\n<img decoding=\"async\" src=\"\/blog\/wp-content\/plugins\/wp-downloadmanager\/images\/ext\/unknown.gif\" alt=\"\" title=\"\" style=\"vertical-align: middle;\" \/>&nbsp;&nbsp;<strong><a href=\"https:\/\/www.nooblet.org\/blog\/download\/ddu.sh\">ddu.sh<\/a><\/strong> (846 bytes, 1,729 hits)<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The command, du (estimate file space usage) is a core Linux program I use often. When trying to find where space is being used on a disk I run the following command: du &#8211;max-depth=1 -xh This produces a list of all directories with their total size in human readable format. However it isn&#8217;t sorted, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-886","post","type-post","status-publish","format-standard","hentry","category-other"],"_links":{"self":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/comments?post=886"}],"version-history":[{"count":6,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/886\/revisions"}],"predecessor-version":[{"id":893,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/886\/revisions\/893"}],"wp:attachment":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media?parent=886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/categories?post=886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/tags?post=886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}