[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61884: add an option to du that allows to control which file types a
From: |
Glenn Golden |
Subject: |
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@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