snipt

Ctrl+h for KB shortcuts

Text only

du for file sizes

1
2
3
4
5
6
7
#for listing also file and 1st level directory sizes.. in this way you can use

du -sh */

#The drawback is that it doesn't list hidden files and directories.. but you can use it when you are sure that there aren't any in the directory :) And the last one, often used by me:

du -sk * | sort -n
https://snipt.net/embed/29d39edc4f5fdcfd0a6761cb2859192c/
/raw/29d39edc4f5fdcfd0a6761cb2859192c/
29d39edc4f5fdcfd0a6761cb2859192c
text
Text only
7
2019-08-23T08:08:45
True
False
False
Aug 01, 2012 at 10:20 AM
/api/public/snipt/44879/
du-for-file-sizes
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>#for listing also file and 1st level directory sizes.. in this way you can use </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>du -sh */ </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>#The drawback is that it doesn&#39;t list hidden files and directories.. but you can use it when you are sure that there aren&#39;t any in the directory :) And the last one, often used by me: </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>du -sk * | sort -n </span></pre></div> </td></tr></table>
du

Bash

Determine size of directories in linux

du -h --max-depth=1 .
https://snipt.net/embed/857ebb68495f6f066f6afb4c1a376a73/
/raw/857ebb68495f6f066f6afb4c1a376a73/
857ebb68495f6f066f6afb4c1a376a73
bash
Bash
1
2019-08-23T14:31:50
True
False
False
/api/public/snipt/37504/
determine-size-of-directories-in-linux
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>du -h --max-depth<span class="o">=</span><span class="m">1</span> . </span></pre></div> </td></tr></table>
"directory size", du, linux

Bash

Tamaño de las carpetas ordenado de menor a mayor

1
2
3
du -hs $(du -s * | sort -g | awk '{print $2}')

du -hs $(du -s .[!.]* * | sort -g | awk '{print $2}')
https://snipt.net/embed/57f9282839d36be8fa232db32277a725/
/raw/57f9282839d36be8fa232db32277a725/
57f9282839d36be8fa232db32277a725
bash
Bash
3
2019-08-23T08:43:34
True
False
False
Oct 28, 2015 at 08:09 AM
/api/public/snipt/25454/
tamano-de-las-carpetas-ordenado-de-menor-a-mayor
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>du -hs <span class="k">$(</span>du -s * <span class="p">|</span> sort -g <span class="p">|</span> awk <span class="s1">&#39;{print $2}&#39;</span><span class="k">)</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>du -hs <span class="k">$(</span>du -s .<span class="o">[</span>!.<span class="o">]</span>* * <span class="p">|</span> sort -g <span class="p">|</span> awk <span class="s1">&#39;{print $2}&#39;</span><span class="k">)</span> </span></pre></div> </td></tr></table>
bash, du, linux, ordenado, tamaño

Bash

size of directories

du -h —max-depth=1
https://snipt.net/embed/2d3e9e6a9e751abac1efdb0a23c48c2d/
/raw/2d3e9e6a9e751abac1efdb0a23c48c2d/
2d3e9e6a9e751abac1efdb0a23c48c2d
bash
Bash
1
2019-08-22T07:11:32
True
False
False
/api/public/snipt/8554/
size-of-directories
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>du -h —max-depth<span class="o">=</span>1 </span></pre></div> </td></tr></table>
cmd, du, filesys, unix

Bash

List every file and subdirectory in the current directory sorted by size

du -sk ./* | sort -n | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
https://snipt.net/embed/5f2a3a47ae3928df44894d969a7191f0/
/raw/5f2a3a47ae3928df44894d969a7191f0/
5f2a3a47ae3928df44894d969a7191f0
bash
Bash
1
2019-08-19T14:05:29
True
False
False
/api/public/snipt/6387/
list-every-file-and-subdirectory-in-the-current-directory-sorted-by-size
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>du -sk ./* <span class="p">|</span> sort -n <span class="p">|</span> awk <span class="s1">&#39;BEGIN{ pref[1]=&quot;K&quot;; pref[2]=&quot;M&quot;; pref[3]=&quot;G&quot;;} { total = total + $1; x = $1; y = 1; while( x &gt; 1024 ) { x = (x + 1023)/1024; y++; } printf(&quot;%g%s\t%s\n&quot;,int(x*10)/10,pref[y],$2); } END { y = 1; while( total &gt; 1024 ) { total = (total + 1023)/1024; y++; } printf(&quot;Total: %g%s\n&quot;,int(total*10)/10,pref[y]); }&#39;</span> </span></pre></div> </td></tr></table>
awk, bash, du, sort

Bash

Disk Space Total

du -sh
https://snipt.net/embed/596da452ce79dfa8589373b7b0a90d86/
/raw/596da452ce79dfa8589373b7b0a90d86/
596da452ce79dfa8589373b7b0a90d86
bash
Bash
1
2019-08-25T11:32:45
True
False
False
/api/public/snipt/3360/
disk-space-total
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>du -sh </span></pre></div> </td></tr></table>
"disk space", du, total

Bash

Grep Total Disk Space of Directory

 du -ch | grep total
https://snipt.net/embed/96346836fbc860889c935dd3d4fb1239/
/raw/96346836fbc860889c935dd3d4fb1239/
96346836fbc860889c935dd3d4fb1239
bash
Bash
1
2019-08-20T20:03:06
True
False
False
/api/public/snipt/3359/
grep-total-disk-space-of-directory
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> du -ch <span class="p">|</span> grep total </span></pre></div> </td></tr></table>
"disk space", du