GNU bug report logs - #61884
add an option to du that allows to control which file types are counted

Previous Next

Package: coreutils;

Reported by: Christoph Anton Mitterer <calestyo <at> scientia.org>

Date: Wed, 1 Mar 2023 03:20:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 61884 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Golden <gdg <at> zplane.com>
To: Christoph Anton Mitterer <calestyo <at> scientia.org>
Cc: 61884 <at> debbugs.gnu.org, Pádraig Brady <P <at> draigbrady.com>
Subject: Re: bug#61884: add an option to du that allows to control which file
 types are counted
Date: Thu, 2 Mar 2023 10:20:35 -0700
Hi Christoph,

Christoph Anton Mitterer <calestyo <at> scientia.org> [2023-03-02 17:54:09 +0100]:
> On Thu, 2023-03-02 at 16:01 +0000, Pádraig Brady wrote:
> > There are many possible filtering options,
> > which are probably best left to `find` (as per your example).
> > This was also mentioned previously at:
> > https://lists.gnu.org/archive/html/coreutils/2013-04/msg00043.html
> 
> 
> Sure, but the problem with all these is that one doesn't get usable
> per-operand totals - only one big overall total.
> 
> If you take e.g.:
> 
> 
> find dir1 dir2 fileA -not -type d -print0 | du -hsc --files0-from=-
> 
> (without the tail), one get's one line per (non-directory) file below
> dir1 and dir2 as well as one for fileA .. plus the grand overall total,
> whereas it would be nice to have totals for:
> - dir1
> - dir2
> - fielA
> - overall
> 

Would something like this work for you?

    ----------------------------------------------------------------
    $ echo dir1_file1 > dir1/file1
    $ echo dir1_file2 > dir1/file2
    $ echo dir2_file1 > dir2/file1
    $ echo dir2_file2 > dir2/file2
    $ echo somefile > fileA

    $ find dir1 dir2 fileA -not -type d -print0 | xargs --null du -hsc
    4.0K    dir1/file2
    4.0K    dir1/file1
    4.0K    dir2/file2
    4.0K    dir2/file1
    4.0K    fileA
    20K     total
    ----------------------------------------------------------------

- Glenn




This bug report was last modified 2 years and 128 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.