05.10.2019 13:42, David T-G пишет:
David, et al --
...and then David Haller said... % % Hello, % % On Fri, 04 Oct 2019, David T-G wrote: % [..] % >I want to get a du total for all of the DIR-* subdirs, grouped by parent, % >without throwing any errors. The simple version obviously doesn't work: % [..] % >What I'd really like is to be able to [ -d $D/DIR-* ] but of course that % >doesn't work because there can be multiple matches. Got any better ideas? % % $ find bla/ -type d -exec du -hkc {} +
OK, so I thought that this wouldn't work nicely, but when testing it I actually noticed the + at the end, and I kinda like it! So I'm going to have to read up on that later today and report back... Thanks!
This won't summarize by top level directories if this is what you need. Something like for i in 2*/; do find "$i" -maxdepth 1 -type d -name DIR-\* -exec du -chk '{}' +; done will. Note that if you may have very large number of DIR-* entries this will result in several invocations of du and so total summary will be wrong (or better you will get several summaries for the same top level directory). P.S. your original question is literally beaten to death. At the end the only way to check whether there are files matching glob pattern is to actually expand it with real file names. Your choice is only how to check result of expansion (or that there is any result of expansion). For that matter the most simple is "ls $i/DIR-* > /dev/null 2>&1". -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org