<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Sniptools &#187; Hosting</title> <atom:link href="http://sniptools.com/tag/hosting/feed/" rel="self" type="application/rss+xml" /><link>http://sniptools.com</link> <description>Design &#38; Technology Observations</description> <lastBuildDate>Tue, 15 May 2012 09:23:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Find and list large files on Linux (or Unix, BSD, Mac OSX)</title><link>http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx</link> <comments>http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx#comments</comments> <pubDate>Mon, 24 Jul 2006 04:20:21 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[System Maintenance]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[Hosting]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Mac OSX]]></category><guid
isPermaLink="false">http://sniptools.com/?p=537</guid> <description><![CDATA[There are several ways to do this, the most prevalent among sys admins being this: find &#123;/path/to/folder/&#125; -type f -size +&#123;size-in-kb&#125;k -exec ls -lh &#123;&#125; \; &#124; awk '{ print $9 &#34;: &#34; $5 }' Which lists the largest files in the folder /path/to/folder. You could just use the ls command too, as such: ls [...]]]></description> <content:encoded><![CDATA[<p>There are several ways to do this, the most prevalent among sys admins being this:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>folder<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-size</span> +<span style="color: #7a0874; font-weight: bold;">&#123;</span>size-in-kb<span style="color: #7a0874; font-weight: bold;">&#125;</span>k <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $9 &quot;: &quot; $5 }'</span></pre></div></div><p>Which lists the largest files in the folder <code>/path/to/folder</code>. You could just use the <code>ls</code> command too, as such:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lhS</span></pre></div></div><p>But there is a simpler, more efficient method to do this:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-xak</span> .<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-50</span></pre></div></div><p>But the best method involves a small Perl hack that shows a very neatly laid out listing of largest files:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-k</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf  (&quot;%6.1f\t%s\t%25s  %s\n&quot;,($1/(2**(10*$m))),((&quot;K&quot;,&quot;M&quot;,&quot;G&quot;,&quot;T&quot;,&quot;P&quot;)[$m]),&quot;*&quot;x (1.5*$l),$2);}'</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 4/7 queries in 0.002 seconds using disk: basic
Object Caching 529/532 objects using disk: basic

Served from: sniptools.com @ 2012-05-17 20:21:02 -->
