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


Groups > linux.debian.user > #269925

Re: tree with dir size

From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: tree with dir size
Date 2024-06-04 16:50 +0200
Message-ID <ILDE5-yuR-1@gated-at.bofh.it> (permalink)
References (5 earlier) <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> <ILDE5-yuR-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Jun 04, 2024 at 04:40:07PM +0200, Franco Martelli wrote:
> 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:

That's because you're passing directories with a trailing / from your
shell.  Probably because you're using tab completions.

If you pass "/usr/local" as the argument instead of

> ~# 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/

you will see that you've broken it now.

If you really care about removing the double slashes from the case
where you pass an extra trailing slash in your input, you should use
parameter expansions or some other filtering to remove one of the
slashes.  That would be better than breaking your function.

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

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