bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45987: Why can't I exclude when using ** with du?


From: Pádraig Brady
Subject: bug#45987: Why can't I exclude when using ** with du?
Date: Tue, 19 Jan 2021 23:42:21 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0

On 19/01/2021 22:36, Maurice R Volaski wrote:
On 1/19/21, 4:49 PM, "Pádraig Brady" <pixelbeat@gmail.com on behalf of 
P@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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]