<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Tip: How to sort folders by size with one command line in Linux</title> <atom:link href="http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/feed/" rel="self" type="application/rss+xml" /><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/</link> <description>The Journal Of A Linux Sysadmin</description> <lastBuildDate>Thu, 18 Mar 2010 16:00:17 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: fab</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-2/#comment-181544</link> <dc:creator>fab</dc:creator> <pubDate>Wed, 27 Jan 2010 20:05:07 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181544</guid> <description>One another :du –si */ .[^.]*/ &#124; sort -n &#124; while read a; do echo â€ $aâ€; done &#124; sed -r ’s/^\ *([\ 0-9]{3})([\ 0-9]{3})([ 0-9]{3})\ *(.*)\/$/\1 \2 \3 \4/’ &#124; egrep -v “k\ “ &#124; grep du -shx * &#124; perl -e ‘%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3, “” =&gt; 4 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { /^(\d+(?:\.\d+){0,1})(\S)/; [ $_, $2, $1 ] } &amp;lt&amp;gt’ &#124; sed s -laQ &#124; grep -r ‘^d’ &#124; grep -v ‘\ \”\.\”$’ &#124; grep -v ‘\ \”\.\.\”$’ &#124; sed -r ’s/.*\ \”(.*)\”$/\1/’ &#124; while read a; do du -s “$a”; done &#124; sort -n &#124; sed -r ’s/^([0-9]{1,4})\t(.*)/ \1\t\2/’ &#124; sed -r ’s/^([\ 0-9]{4,5})\t(.*)/ \1\t\2/’ &#124; sed -r ’s/^([\ 0-9]{6})\t(.*)/ \1\t\2/’ &#124; sed -r ’s/^([\ 0-9])([\ 0-9]{3})([\ 0-9]{3})\t(.*)/\1 \2 \3\t\4/’  –all –max-depth=1 $@ &#124; sort -n &#124; awk ‘{if ($1&gt;1048576) {print int($1/1048576)”G”,$2}else if ($1&gt;1024) {print int($1/1024)”M”,$2} else {print $1?K”,$2}}’</description> <content:encoded><![CDATA[<p>One another :</p><p>du –si */ .[^.]*/ | sort -n | while read a; do echo â€ $aâ€; done | sed -r ’s/^\ *([\ 0-9]{3})([\ 0-9]{3})([ 0-9]{3})\ *(.*)\/$/\1 \2 \3 \4/’ | egrep -v “k\ “ | grep du -shx * | perl -e ‘%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3, “” =&gt; 4 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} || $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { /^(\d+(?:\.\d+){0,1})(\S)/; [ $_, $2, $1 ] } &amp;lt&amp;gt’ | sed s -laQ | grep -r ‘^d’ | grep -v ‘\ \”\.\”$’ | grep -v ‘\ \”\.\.\”$’ | sed -r ’s/.*\ \”(.*)\”$/\1/’ | while read a; do du -s “$a”; done | sort -n | sed -r ’s/^([0-9]{1,4})\t(.*)/ \1\t\2/’ | sed -r ’s/^([\ 0-9]{4,5})\t(.*)/ \1\t\2/’ | sed -r ’s/^([\ 0-9]{6})\t(.*)/ \1\t\2/’ | sed -r ’s/^([\ 0-9])([\ 0-9]{3})([\ 0-9]{3})\t(.*)/\1 \2 \3\t\4/’  –all –max-depth=1 $@ | sort -n | awk ‘{if ($1&gt;1048576) {print int($1/1048576)”G”,$2}else if ($1&gt;1024) {print int($1/1024)”M”,$2} else {print $1?K”,$2}}’</p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-2/#comment-181488</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 07 Jan 2010 21:41:46 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181488</guid> <description>Actually sub K file sizes remain a bug.  A match for null case is needed. Also decimal values break the new regex.  That needs to be accounted for in the pattern. This one should be final:du -shx * &#124; perl -e &#039;%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3, &quot;&quot; =&gt; 4 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { /^(\d+(?:\.\d+){0,1})(\S)/; [ $_, $2, $1 ] } &amp;lt&amp;gt&#039;</description> <content:encoded><![CDATA[<p>Actually sub K file sizes remain a bug.  A match for null case is needed. Also decimal values break the new regex.  That needs to be accounted for in the pattern. This one should be final:</p><p>du -shx * | perl -e &#8216;%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3, &#8220;&#8221; =&gt; 4 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} || $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { /^(\d+(?:\.\d+){0,1})(\S)/; [ $_, $2, $1 ] } &amp;lt&amp;gt&#8217;</p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-2/#comment-181487</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 07 Jan 2010 18:57:13 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181487</guid> <description>Sure, just need to bump the numbering in the byte_order hash over and add T to the regex match.du -shx &#124; perl -e ‘%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { [ $_, /([MTGK])/, /(\d+)/ ] } &amp;lt&amp;gt’Though it is probably better still to change the regex from /([MTGK])/ to /^\d+(\S)/ Since that will match more generically and not at all on sub K output lines, as it should.Or even better still (only runs the regex once for each line):du -shx &#124; perl -e ‘%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { /^(\d+)(\S)/; [ $_, $2, $1 ] } &amp;lt&amp;gt’</description> <content:encoded><![CDATA[<p>Sure, just need to bump the numbering in the byte_order hash over and add T to the regex match.</p><p>du -shx | perl -e ‘%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} || $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { [ $_, /([MTGK])/, /(\d+)/ ] } &amp;lt&amp;gt’</p><p>Though it is probably better still to change the regex from /([MTGK])/ to /^\d+(\S)/ Since that will match more generically and not at all on sub K output lines, as it should.</p><p>Or even better still (only runs the regex once for each line):</p><p>du -shx | perl -e ‘%byte_order = ( T =&gt; 0, G =&gt; 1, M =&gt; 2, K =&gt; 3 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} || $b-&gt;[2] &amp;lt=&amp;gt $a-&gt;[2] } map { /^(\d+)(\S)/; [ $_, $2, $1 ] } &amp;lt&amp;gt’</p> ]]></content:encoded> </item> <item><title>By: lappy</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-2/#comment-181483</link> <dc:creator>lappy</dc:creator> <pubDate>Thu, 07 Jan 2010 00:30:52 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181483</guid> <description>The script works good with perl, but I&#039;m curious if Terabyte can be added to it too.  I don&#039;t know much perl so it would be great if T can be added in the mix also.
Thanks</description> <content:encoded><![CDATA[<p>The script works good with perl, but I&#8217;m curious if Terabyte can be added to it too.  I don&#8217;t know much perl so it would be great if T can be added in the mix also.<br
/> Thanks</p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-2/#comment-181348</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 03 Dec 2009 22:39:16 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181348</guid> <description>nope, good luck</description> <content:encoded><![CDATA[<p>nope, good luck</p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-1/#comment-181347</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 03 Dec 2009 22:38:31 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181347</guid> <description>du -shx &#124; perl -e &#039;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2] [2] } map { [ $_, /([MGK])/, /(\d+)/ ] } &amp;lt&amp;gt&#039;breaking out the html manaul... &amp;lt$gt..</description> <content:encoded><![CDATA[<p>du -shx | perl -e &#8216;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} &amp;lt=&amp;gt $byte_order{$b-&gt;[1]} || $b-&gt;[2] [2] } map { [ $_, /([MGK])/, /(\d+)/ ] } &amp;lt&amp;gt&#8217;</p><p>breaking out the html manaul&#8230; &amp;lt$gt..</p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-1/#comment-181346</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 03 Dec 2009 22:31:46 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181346</guid> <description>Grrr.. using code flag..
&lt;code&gt;
du -shx &#124; &#124; perl -e &#039;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]}  $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2]  $a-&gt;[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } &#039;
&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Grrr.. using code flag..<br
/> <code><br
/> du -shx | | perl -e '%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]}  $byte_order{$b-&gt;[1]} || $b-&gt;[2]  $a-&gt;[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } '<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-1/#comment-181345</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 03 Dec 2009 22:29:31 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181345</guid> <description>du -shx &#124; perl -e &#039;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} \ $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2] \ $a-&gt;[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } \&#039;command needed some commenting to get past the \s probably html interpretation.</description> <content:encoded><![CDATA[<p>du -shx | perl -e &#8216;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]} \ $byte_order{$b-&gt;[1]} || $b-&gt;[2] \ $a-&gt;[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } \&#8217;</p><p>command needed some commenting to get past the \s probably html interpretation.</p> ]]></content:encoded> </item> <item><title>By: Fusiondog</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-1/#comment-181344</link> <dc:creator>Fusiondog</dc:creator> <pubDate>Thu, 03 Dec 2009 22:24:56 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181344</guid> <description>Here is only one run of du and no temp files.  It is about as efficient as you can get.du -shx &#124; perl -e &#039;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]}  $byte_order{$b-&gt;[1]} &#124;&#124; $b-&gt;[2]  $a-&gt;[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } &#039;</description> <content:encoded><![CDATA[<p>Here is only one run of du and no temp files.  It is about as efficient as you can get.</p><p>du -shx | perl -e &#8216;%byte_order =  ( G =&gt; 0, M =&gt; 1, K =&gt; 2 ); print map { $_-&gt;[0] } sort { $byte_order{$a-&gt;[1]}  $byte_order{$b-&gt;[1]} || $b-&gt;[2]  $a-&gt;[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } &#8216;</p> ]]></content:encoded> </item> <item><title>By: meingbg</title><link>http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/comment-page-1/#comment-181278</link> <dc:creator>meingbg</dc:creator> <pubDate>Sat, 14 Nov 2009 17:17:49 +0000</pubDate> <guid
isPermaLink="false">http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/#comment-181278</guid> <description>To have it done fast, just use quota. Or pick your favourite version above, just stay away from the ones with more than one call to du.</description> <content:encoded><![CDATA[<p>To have it done fast, just use quota. Or pick your favourite version above, just stay away from the ones with more than one call to du.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 9/24 queries in 0.007 seconds using memcached

Served from: www.ducea.com @ 2010-03-19 19:22:01 -->