Archives

Creative Commons License
This blog is licensed under a Creative Commons License.

Script of the week: sizes

| 1 Comment | No TrackBacks

For the next few months, I will have a “script of the week” each week: just some tiny little scripts I’ve developed over the years that I happen to find particularly useful.

Today’s is a shell script called sizes. It’s a fairly simplistic interface to the du commands which just shows you all files and directories in the current directory that are larger than one megabyte.

Here’s an example of running it in my /Library directory:

~/Library $ sizes
2.8M   Scripts
3.9M   Components
5.6M   Java
6.0M   QuickTime
6.1M   PreferencePanes
7.6M   TexPackages
 12M   Keychains
 15M   Fonts
 20M   Preferences
 36M   Logs
 51M   Lisp
 55M   Emacs
 86M   Backups
398M   Application Support
1.7G   Caches

Here’s the script:

#!/bin/sh

du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
    egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/sizes.$$

egrep '^ *[0-9.]*M' /tmp/sizes.$$
egrep '^ *[0-9.]*G' /tmp/sizes.$$

rm -f /tmp/sizes.$$

No TrackBacks

TrackBack URL: http://www.newartisans.com/mt/mt-tb.cgi/32

1 Comment

du -sx *| egrep ‘^[0-9]{3,}’ | sort -n| awk ‘BEGIN {u[0]=k;u[1]=”M”;u[2]=”G”;} {for (i=3;i>0;–i) { if ( $1 > 1024 ^i) {printf “%.2f%st%sn”,($1 / 1024^i),u[i],$2;next}}}’

About this Entry

This page contains a single entry by John Wiegley published on October 27, 2007 5:39 AM.

The groovy thing about Groovy was the previous entry in this blog.

A regular expression IDE for Emacs is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Recent Comments

  • Curt Sampson: That there’s “no state” in Haskell is quite wrong; in read more
  • rv: Hi. I wanted to drop you a quick note to read more
  • John Wiegley: It’s here: http://ftp.newartisans.com/pub/python/modpython_gateway.py read more
  • Leon: The file “modpython_gateway.py” Is no longer available in the downloads read more
  • Kathy: Well, the article is really the sweetest on this laudable read more
  • mr.design: Hi John, I just started to read your GFTBU, it’s read more
  • yoman: “Barfin”? “Slurping”? “Slime” “Hunchentoot” ??? What in the T.F. world read more
  • John Wiegley: Something like this is slated for the next release of read more
  • womens health: According to me, Apple has implemented something called blocks, which read more
  • Bjorn Tipling: Why would you add instructions for installing an editor when read more
OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.261