Re: du

[prev] [thread] [next] [lurker] [Date index for 2005/09/30]

From: Luke Kanies
Subject: Re: du
Date: 16:21 on 30 Sep 2005
On Fri, 30 Sep 2005, Abigail wrote:

> On Fri, Sep 30, 2005 at 11:06:26AM +0200, S?bastien Aperghis-Tramoni wrote:
> >
> > I usually use  du -hs .??*  in order to list all hidden files except
> > current and parent directories.
>
>
> I happen to have a directory .S in my home directory - which would be
> missed by .??*.
>
>     du -hs .[^.]* ..?*
>
> ought to do the trick.

This is exactly why I use the shell for interactive stuff only, and I
rely more on grepping out the info I don't want than on making sure only
it appears in the first place.

Because, of course, the above line will result in crap you don't want if
you don't happen to have directories that match your strings:

    $ echo .[^.]* ..?*
    .svn ..?*

This is why regular expressions are better than shell metacharacters:
They are actually matching, not expanding.  Globbing is great, and is
certainly related to the current twisted but good state of regexes, but
I like to think I've moved on.

    du $(ruby -e 'Dir.entries(".").reject { |d|
        d =~ /^\.\.?$/
    }.each { |d|
        puts d
    }')

Yes, it's more typing, but that's what aliases and scripts are for, and
I'm guessing some well-applied golf skills could reduce it some (and I
bet you could reduce it a bit in perl or especially awk), but this is
downright clear to me, and provides much more of a guarantee to me that
I get what I want and don't get crap I don't want.

Oh, and I always use '-sk' on those platforms that support it, and I
always cuss like a sailor at those platforms that don't.

-- 
Silence is a text easy to misread.
    -- A. A. Attanasio, 'The Eagle and the Sword'
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://config.sage.org

There's stuff above here

Generated at 16:00 on 04 Oct 2005 by mariachi 0.52