Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #269926

Re: tree with dir size

From Franco Martelli <martellif67@gmail.com>
Newsgroups linux.debian.user
Subject Re: tree with dir size
Date 2024-06-04 16:50 +0200
Message-ID <ILDE5-yuR-3@gated-at.bofh.it> (permalink)
References (6 earlier) <ILh0R-kDd-7@gated-at.bofh.it> <ILmMV-o6h-1@gated-at.bofh.it> <ILolH-p9f-13@gated-at.bofh.it> <ILrtf-qXB-5@gated-at.bofh.it> <ILrtf-qXB-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 04/06/24 at 03:48, Greg Wooledge wrote:
> On Mon, Jun 03, 2024 at 07:42:17PM -0500, David Wright wrote:
>> On Mon 03 Jun 2024 at 18:29:17 (-0400), Greg Wooledge wrote:
>>> ‘-s’
>>> ‘--summarize’
>>>       Display only a total for each argument.
>>>
>>> There's supposed to be a total *FOR EACH ARGUMENT*.  There isn't.
>>
>> Try adding -l. The idea is that du is trying to avoid double-counting,
>> so when the subdirectories come first, those ones are "used up" by
>> the time it reaches the parent. When the parent is first, it's (all)
>> the subdirectories instead that have been "used up".
> 
> ‘-l’
> ‘--count-links’
>       Count the size of all files, even if they have appeared already (as
>       a hard link).
> 
> This documentation leaves a lot to be desired.
> 
> Anyway, you are correct about the result, even if the documentation gives
> no realistic way to conclude such a result.
> 
> hobbit:~$ printf '%s\0' "${1:-.}" "${1:-.}"/*/ | xargs -0 du -shl
> 684M    /usr/local
> 81M     /usr/local/bin/
> 4.0K    /usr/local/etc/
> 4.0K    /usr/local/games/
> 136K    /usr/local/include/
> 45M     /usr/local/lib/
> 29M     /usr/local/man/
> 8.0K    /usr/local/sbin/
> 31M     /usr/local/share/
> 484M    /usr/local/src/
> 44M     /usr/local/tcl8.6/
> 

FYI the revision of duhs() I adopt is:

duhs() { ( shopt -s dotglob; printf '%s\0' "${1:-.}" "${1:-.}"*/ | xargs 
-0 du -shl ) }                                                ↑

Please note that I dropped a "/" in the "${1:-.}"/*/ block because the 
directories listed had a double "//" in their names:

~# duhs /usr/local/
88K     /usr/local/
4,0K    /usr/local//bin/
4,0K    /usr/local//etc/
4,0K    /usr/local//games/
4,0K    /usr/local//include/
4,0K    /usr/local//man/
4,0K    /usr/local//sbin/
60K     /usr/local//share/
4,0K    /usr/local//src/

Thank again,
Cheers,
-- 
Franco Martelli

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

tree with dir size Northwind <nw@secubox.org> - 2024-05-31 00:30 +0200
  Re: tree with dir size eben@gmx.us - 2024-05-31 01:00 +0200
    Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-05-31 01:00 +0200
      Re: tree with dir size Northwind <nw@secubox.org> - 2024-05-31 01:00 +0200
        Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-05-31 01:10 +0200
      Re: tree with dir size eben@gmx.us - 2024-05-31 02:10 +0200
        Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-05-31 02:20 +0200
          Re: tree with dir size Franco Martelli <martellif67@gmail.com> - 2024-05-31 21:20 +0200
            Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-05-31 22:10 +0200
              Re: tree with dir size David Wright <deblis@lionunicorn.co.uk> - 2024-06-01 04:40 +0200
                Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-06-01 05:20 +0200
                Re: tree with dir size Lee <ler762@gmail.com> - 2024-06-01 16:20 +0200
              Re: tree with dir size Franco Martelli <martellif67@gmail.com> - 2024-06-03 16:00 +0200
                Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-06-03 16:40 +0200
                Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-06-03 21:10 +0200
                Re: tree with dir size David Wright <deblis@lionunicorn.co.uk> - 2024-06-04 02:40 +0200
                Re: tree with dir size Franco Martelli <martellif67@gmail.com> - 2024-06-03 22:50 +0200
                Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-06-04 00:30 +0200
                Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-06-04 03:50 +0200
                Re: tree with dir size Greg Wooledge <greg@wooledge.org> - 2024-06-04 16:50 +0200
                Re: tree with dir size Franco Martelli <martellif67@gmail.com> - 2024-06-04 16:50 +0200
                Re: tree with dir size Andy Smith <andy@strugglers.net> - 2024-06-03 16:40 +0200
                Re: tree with dir size <tomas@tuxteam.de> - 2024-06-03 19:10 +0200
                Re: tree with dir size Franco Martelli <martellif67@gmail.com> - 2024-06-03 23:00 +0200
                Re: tree with dir size <tomas@tuxteam.de> - 2024-06-03 16:40 +0200
  Re: tree with dir size Sridhar M A <alaymari@gmail.com> - 2024-05-31 02:50 +0200
  Re: tree with dir size Felix Miata <mrmazda@earthlink.net> - 2024-05-31 03:30 +0200

csiph-web