Hadoop fs -du-h sorting by size for M, G, T, P, E, Z, Y
<p>I am running this command --</p>

<pre><code>sudo -u hdfs hadoop fs -du -h /user | sort -nr 
</code></pre>

<p>and the output is not sorted in terms of gigs, Terabytes,gb </p>

<p>I found this command - </p>

<pre><code>hdfs dfs -du -s /foo/bar/*tobedeleted | sort -r -k 1 -g | awk '{ suffix="KMGT"; for(i=0; $1&gt;1024 &amp;&amp; i &lt; length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }' 
</code></pre>

<p>but did not seem to work.</p>

<p>is there a way or a command line flag i can use to make it sort and output should look like--</p>

<pre><code>123T  /xyz
124T  /xyd
126T  /vat
127G  /ayf
123G  /atd
</code></pre>

<p>Please help</p>

<p>regards
Mayur</p>