GNU bug report logs - #45987
Why can't I exclude when using ** with du?

Previous Next

Package: coreutils;

Reported by: Maurice R Volaski <maurice.volaski <at> einsteinmed.org>

Date: Tue, 19 Jan 2021 18:22:01 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45987 in the body.
You can then email your comments to 45987 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#45987; Package coreutils. (Tue, 19 Jan 2021 18:22:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maurice R Volaski <maurice.volaski <at> einsteinmed.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 19 Jan 2021 18:22:01 GMT) Full text and rfc822 format available.

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

From: Maurice R Volaski <maurice.volaski <at> einsteinmed.org>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: Why can't I exclude when using ** with du?
Date: Tue, 19 Jan 2021 17:31:07 +0000
[Message part 1 (text/plain, inline)]
If I set globstar and use it as follows with exclude, the excluded option is ignored. That is, the folder named “users” is descended into. Is that the intended behavior? Is there a workaround?

du -a --exclude=users  **/*.dat
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#45987; Package coreutils. (Tue, 19 Jan 2021 21:50:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Maurice R Volaski <maurice.volaski <at> einsteinmed.org>, 45987 <at> debbugs.gnu.org
Subject: Re: bug#45987: Why can't I exclude when using ** with du?
Date: Tue, 19 Jan 2021 21:49:16 +0000
tag 45987 notabug
close 45987
stop

On 19/01/2021 17:31, Maurice R Volaski wrote:
> If I set globstar and use it as follows with exclude, the excluded option is ignored. That is, the folder named “users” is descended into. Is that the intended behavior? Is there a workaround?
> 
> du -a --exclude=users  **/*.dat

du will not recurse into dirs called 'users',
however your shell is doing the recursing
and specifying all the .dat files to du.
du will only ignore the last component of specified files.

To demonstrate:


$ echo **/*.dat
users/1/blah.dat users/2/blah.dat

$ du -a --exclude=users **/*.dat
0	users/1/blah.dat
0	users/2/blah.dat


$ echo **/users
users users/2/users

$ du -a --exclude=users **/users  # All ignored
$ du -a --exclude=users users     # All ignored

cheers,
Pádraig




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Tue, 19 Jan 2021 21:50:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 45987 <at> debbugs.gnu.org and Maurice R Volaski <maurice.volaski <at> einsteinmed.org> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Tue, 19 Jan 2021 21:50:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#45987; Package coreutils. (Tue, 19 Jan 2021 23:18:02 GMT) Full text and rfc822 format available.

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

From: Maurice R Volaski <maurice.volaski <at> einsteinmed.org>
To: Pádraig Brady <P <at> draigBrady.com>,
 "45987 <at> debbugs.gnu.org" <45987 <at> debbugs.gnu.org>
Subject: Re: bug#45987: Why can't I exclude when using ** with du?
Date: Tue, 19 Jan 2021 22:36:24 +0000
Do you think there is any way to do this action with du, then?

On 1/19/21, 4:49 PM, "Pádraig Brady" <pixelbeat <at> gmail.com on behalf of P <at> draigBrady.com> wrote:

    CAUTION: This email comes from an external source; the attachments and/or links may compromise our secure environment. Do not open or click on suspicious emails. Please click on the “Phish Alert” button on the top right of the Outlook dashboard to report any suspicious emails.

    tag 45987 notabug
    close 45987
    stop

    On 19/01/2021 17:31, Maurice R Volaski wrote:
    > If I set globstar and use it as follows with exclude, the excluded option is ignored. That is, the folder named “users” is descended into. Is that the intended behavior? Is there a workaround?
    >
    > du -a --exclude=users  **/*.dat

    du will not recurse into dirs called 'users',
    however your shell is doing the recursing
    and specifying all the .dat files to du.
    du will only ignore the last component of specified files.

    To demonstrate:


    $ echo **/*.dat
    users/1/blah.dat users/2/blah.dat

    $ du -a --exclude=users **/*.dat
    0       users/1/blah.dat
    0       users/2/blah.dat


    $ echo **/users
    users users/2/users

    $ du -a --exclude=users **/users  # All ignored
    $ du -a --exclude=users users     # All ignored

    cheers,
    Pádraig


Information forwarded to bug-coreutils <at> gnu.org:
bug#45987; Package coreutils. (Tue, 19 Jan 2021 23:43:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Maurice R Volaski <maurice.volaski <at> einsteinmed.org>,
 "45987 <at> debbugs.gnu.org" <45987 <at> debbugs.gnu.org>
Subject: Re: bug#45987: Why can't I exclude when using ** with du?
Date: Tue, 19 Jan 2021 23:42:21 +0000
On 19/01/2021 22:36, Maurice R Volaski wrote:
>> On 1/19/21, 4:49 PM, "Pádraig Brady" <pixelbeat <at> gmail.com on behalf of P <at> draigBrady.com> wrote:

>> 
>>      On 19/01/2021 17:31, Maurice R Volaski wrote:
>>      > If I set globstar and use it as follows with exclude, the excluded option is ignored. That is, the folder named “users” is descended into. Is that the intended behavior? Is there a workaround?
>>      >
>>      > du -a --exclude=users  **/*.dat
>> 
>>      du will not recurse into dirs called 'users',
>>      however your shell is doing the recursing
>>      and specifying all the .dat files to du.
>>      du will only ignore the last component of specified files.
>> 
>>      To demonstrate:
>> 
>> 
>>      $ echo **/*.dat
>>      users/1/blah.dat users/2/blah.dat
>> 
>>      $ du -a --exclude=users **/*.dat
>>      0       users/1/blah.dat
>>      0       users/2/blah.dat
>> 
>> 
>>      $ echo **/users
>>      users users/2/users
>> 
>>      $ du -a --exclude=users **/users  # All ignored
>>      $ du -a --exclude=users users     # All ignored

> Do you think there is any way to do this action with du, then?

Well du does not have an --include option.
So it would be best to combine find with du for this.
Something like:

  find -type f -name '*.dat' -print0 | du -a --files0-from=-

cheers,
Pádraig.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 17 Feb 2021 12:24:16 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 60 days ago.

Previous Next


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