Archive for the ‘Linux’ category

Just discovered a better/faster way to get the directory size on linux

August 28th, 2008

I’d always read that to get the total size of a directory (and everything below it) on linux you use du -ch | grep total

This works but gets slower the more files/folders a directory contains.  Then I remembered the tail program and presto — my life just got easier. du -ch | tail -n 1 will give exactly the same output as grep total and takes no time.

I know a lot of people who find this will be like… duh! But oh well, I’m happy about my discovery and now feel like I’ve accomplished something today.