<?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>drjason.com &#187; perl</title>
	<atom:link href="http://www.drjason.com/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drjason.com</link>
	<description>Dr Perky sucks.</description>
	<lastBuildDate>Mon, 06 Feb 2012 06:42:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Find the directories containing the most files</title>
		<link>http://www.drjason.com/2009/03/find-the-directories-containing-the-most-files/</link>
		<comments>http://www.drjason.com/2009/03/find-the-directories-containing-the-most-files/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 20:08:19 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.drjason.com/?p=386</guid>
		<description><![CDATA[I needed to find the directories containing the most files, so I whipped up this bit of voodoo at the command line: find . -type f -print &#124; perl -na -F/ -e 'while (pop @F &#38;&#38; @F) { print join ("/", @F)."\n"; }' &#124; sort &#124; uniq -c &#124; sort -n This will count the [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to find the directories containing the most files, so I whipped up this bit of voodoo at the command line:</p>
<p><code>find . -type f -print | perl -na -F/ -e 'while (pop @F &amp;&amp; @F) { print join ("/", @F)."\n"; }' | sort | uniq -c | sort -n</code></p>
<p>This will count the number of files in each directory beneath your current directory, and print out those directories in ascending order by the number of files they contain.  It will also print totals for parent directories&#8211;if &#8220;foo/bar&#8221; has one file, &#8220;foo/baz&#8221; has two, and &#8220;foo/&#8221; itself has one, then the line for &#8220;foo&#8221; will be printed with the number four.</p>
<p>Handy for me, possibly handy for you as well.  This works in Linux and Mac OS X Leopard.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;title=Find%20the%20directories%20containing%20the%20most%20files&amp;bodytext=I%20needed%20to%20find%20the%20directories%20containing%20the%20most%20files%2C%20so%20I%20whipped%20up%20this%20bit%20of%20voodoo%20at%20the%20command%20line%3A%0D%0A%0D%0Afind%20.%20-type%20f%20-print%20%7C%20perl%20-na%20-F%2F%20-e%20%27while%20%28pop%20%40F%20%26amp%3B%26amp%3B%20%40F%29%20%7B%20print%20join%20%28%22%2F%22%2C%20%40F%29.%22%5Cn%22%3B%20%7D%27%20%7C%20sort%20%7C%20uniq%20-c%20%7C%20sort%20-n%0D%0A%0D" title="Digg"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;title=Find%20the%20directories%20containing%20the%20most%20files&amp;notes=I%20needed%20to%20find%20the%20directories%20containing%20the%20most%20files%2C%20so%20I%20whipped%20up%20this%20bit%20of%20voodoo%20at%20the%20command%20line%3A%0D%0A%0D%0Afind%20.%20-type%20f%20-print%20%7C%20perl%20-na%20-F%2F%20-e%20%27while%20%28pop%20%40F%20%26amp%3B%26amp%3B%20%40F%29%20%7B%20print%20join%20%28%22%2F%22%2C%20%40F%29.%22%5Cn%22%3B%20%7D%27%20%7C%20sort%20%7C%20uniq%20-c%20%7C%20sort%20-n%0D%0A%0D" title="del.icio.us"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;t=Find%20the%20directories%20containing%20the%20most%20files" title="Facebook"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;title=Find%20the%20directories%20containing%20the%20most%20files&amp;annotation=I%20needed%20to%20find%20the%20directories%20containing%20the%20most%20files%2C%20so%20I%20whipped%20up%20this%20bit%20of%20voodoo%20at%20the%20command%20line%3A%0D%0A%0D%0Afind%20.%20-type%20f%20-print%20%7C%20perl%20-na%20-F%2F%20-e%20%27while%20%28pop%20%40F%20%26amp%3B%26amp%3B%20%40F%29%20%7B%20print%20join%20%28%22%2F%22%2C%20%40F%29.%22%5Cn%22%3B%20%7D%27%20%7C%20sort%20%7C%20uniq%20-c%20%7C%20sort%20-n%0D%0A%0D" title="Google Bookmarks"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;title=Find%20the%20directories%20containing%20the%20most%20files" title="Reddit"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;title=Find%20the%20directories%20containing%20the%20most%20files" title="StumbleUpon"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Find%20the%20directories%20containing%20the%20most%20files&amp;body=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F" title="email"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.drjason.com%2F2009%2F03%2Ffind-the-directories-containing-the-most-files%2F&amp;partner=sociable" title="Print"><img src="http://www.drjason.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.drjason.com/2009/03/find-the-directories-containing-the-most-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

