<?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>iantomkins.com &#187; Linux</title>
	<atom:link href="http://iantomkins.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://iantomkins.com</link>
	<description>Just my thoughts</description>
	<lastBuildDate>Tue, 24 Aug 2010 22:13:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to find the total size of all the files in a directory</title>
		<link>http://iantomkins.com/2009/12/find-total-size-files-directory/</link>
		<comments>http://iantomkins.com/2009/12/find-total-size-files-directory/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 12:45:40 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://iantomkins.com/?p=127</guid>
		<description><![CDATA[<p>On Linux systems the command du can provide you with information about file sizes in directories.</p> <p>Usually I use a command like this</p> <p>du -hs</p> <p>or</p> <p>du -h --max-depth=1</p> <p>to produce a quick total of the file sizes in the current directory or first level subdirectories respectively.</p> <p>This is also really handy for doing quick [...]]]></description>
			<content:encoded><![CDATA[<p>On Linux systems the command du can provide you with information about file sizes in directories.</p>
<p>Usually I use a command like this</p>
<p><code>du -hs</code></p>
<p>or</p>
<p><code>du -h --max-depth=1</code></p>
<p>to produce a quick total of the file sizes in the current directory or first level subdirectories respectively.</p>
<p>This is also really handy for doing quick size comparisons when copying files around, however recently I hit a problem when copying files between an old ext3 formatted disk and a new ext4 formatted one that I couldn&#8217;t compare totals and get a reliable figure to compare between the two directories.</p>
<p>So this is what I ended up using:</p>
<p><code>find . -type f -printf %s"\n" | perl -nale '$sum+=$F[0]; print $sum if eof'</code></p>
<p>The crucial element to this is that it only totals regular files and ignores directories (and other objects like pipes and symlinks).  Without the <code>-type f</code> option this produces the same output as <code>du -bs</code> which gives a single byte size count for everything in the current directory.  Also of note is that this uses perl to calculate the total rather than awk as most other similar examples use, this is because I found that awk wants to convert everything to a float when the numbers get large.</p>
]]></content:encoded>
			<wfw:commentRss>http://iantomkins.com/2009/12/find-total-size-files-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

