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


Groups > linux.debian.user > #269866

Re: tree with dir size

From Franco Martelli <martellif67@gmail.com>
Newsgroups linux.debian.user
Subject Re: tree with dir size
Date 2024-06-03 16:00 +0200
Message-ID <ILgo9-kbf-1@gated-at.bofh.it> (permalink)
References (2 earlier) <IJWUx-gZyF-1@gated-at.bofh.it> <IJY0h-h0zf-5@gated-at.bofh.it> <IJY9X-h0Cm-5@gated-at.bofh.it> <IKfXb-hhoO-1@gated-at.bofh.it> <IKgJz-hhTQ-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Greg,
(sorry for the answer's late but I turn off the PC during the weekend) :(

On 31/05/24 at 22:03, Greg Wooledge wrote:
>> It could be improved adding the "-a" switch to show also the hidden
>> directories and the "--color" switch to the "grep" command but this sadly
>> doesn't show the expected result (colorized directories) I don't know why:
>>
>> ~$ tree --du -Fah /tmp/x | grep --color /$
> You're only coloring the trailing / characters.  If you want everything
> from after the last space to the end of the line, you'd want:
> 
>      tree --du -Fh /usr/local | grep --color '[^[:space:]]*/$'

I realized why "tree" command doesn't colorized the directories: "tree" 
detects that its std output goes through a pipe and therefore it 
disables the escaped code to colorize (like also "dmesg" does).
To avoid this behavior you must use the "unbuffer" command:

unbuffer tree --du -Fah /usr/local | grep /$

You can also try:

~# unbuffer dmesg | grep snd

/usr/bin/unbuffer is part of the "expect" package.

...> If you want to avoid that, you can use xargs -0:
> 
>     duhs() { printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh; }
> 
> As printf is a bash builtin, it can handle an unlimited number of
> arguments.  So this form should work in all cases.

Thank you very much for revolutionizing my duhs() function, but sadly 
this version omits to show the hidden directories. Do you have a version 
that it shows also those directories? For me it's so hard to figure out 
what the  "${1:-.}"/*/  block does.
Again, is "man 7 glob" the right read or do you have a better one?

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