Re: tree with dir size

2024-06-04 Thread Greg Wooledge
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

Re: tree with dir size

2024-06-04 Thread Franco Martelli
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'

Re: tree with dir size

2024-06-03 Thread Greg Wooledge
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

Re: tree with dir size

2024-06-03 Thread David Wright
On Mon 03 Jun 2024 at 18:29:17 (-0400), Greg Wooledge wrote: > On Mon, Jun 03, 2024 at 10:45:28PM +0200, Franco Martelli wrote: > > On 03/06/24 at 16:32, Greg Wooledge wrote: > > > duhs() { > > > ( > > >shopt -s dotglob > > >printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh > > >

Re: tree with dir size

2024-06-03 Thread David Wright
On Mon 03 Jun 2024 at 15:03:37 (-0400), Greg Wooledge wrote: > On Mon, Jun 03, 2024 at 01:11:57PM -0500, David Wright wrote: > > On Mon 03 Jun 2024 at 10:32:16 (-0400), Greg Wooledge wrote: > > > duhs() ( > > > shopt -s dotglob > > > printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh > > > ) > >

Re: tree with dir size

2024-06-03 Thread Greg Wooledge
On Mon, Jun 03, 2024 at 10:45:28PM +0200, Franco Martelli wrote: > On 03/06/24 at 16:32, Greg Wooledge wrote: > > duhs() { > > ( > >shopt -s dotglob > >printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh > > ) > > } > > I've some issue with this function. It doesn't show the siz

Re: tree with dir size

2024-06-03 Thread Franco Martelli
On 03/06/24 at 16:36, Andy Smith wrote: unbuffer tree --du -Fah /usr/local | grep /$ If that's the only thing you're using unbuffer for, why not just use the -C option of tree? It's a bit like the "--color=always" of ls. Yeah, RTFMB4 I've all the "aliases" with the "unbuffer" command… Cheer

Re: tree with dir size

2024-06-03 Thread Franco Martelli
On 03/06/24 at 16:32, Greg Wooledge wrote: duhs() { shopt -s dotglob printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh shopt -u dotglob } But this assumes that the option was*not* already on when we entered the function. If it was on, we've just turned it off. Another way to do this

Re: tree with dir size

2024-06-03 Thread Greg Wooledge
On Mon, Jun 03, 2024 at 01:11:57PM -0500, David Wright wrote: > On Mon 03 Jun 2024 at 10:32:16 (-0400), Greg Wooledge wrote: > > duhs() ( > > shopt -s dotglob > > printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh > > ) > > > > I'm not personally fond of this. It's extremely easy to overlook >

Re: tree with dir size

2024-06-03 Thread David Wright
On Mon 03 Jun 2024 at 10:32:16 (-0400), Greg Wooledge wrote: > I'll also throw in one last piece of information because if I don't, > someone else is likely to do it, without a good explanation. > Syntactically, the body of a shell function doesn't have to be enclosed > in curly braces. The body c

Re: tree with dir size

2024-06-03 Thread tomas
On Mon, Jun 03, 2024 at 02:36:43PM +, Andy Smith wrote: [...] > If that's the only thing you're using unbuffer for, why not just use > the -C option of tree? It's a bit like the "--color=always" of ls. Oh, and the complementary option for `less', while we're at it, would be -R: tree -C |

Re: tree with dir size

2024-06-03 Thread Andy Smith
Hi, On Mon, Jun 03, 2024 at 03:52:54PM +0200, Franco Martelli wrote: > "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 -

Re: tree with dir size

2024-06-03 Thread Greg Wooledge
On Mon, Jun 03, 2024 at 03:52:54PM +0200, Franco Martelli wrote: > 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 res

Re: tree with dir size

2024-06-03 Thread tomas
On Mon, Jun 03, 2024 at 03:52:54PM +0200, Franco Martelli wrote: > > > > > > ~$ 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/loc

Re: tree with dir size

2024-06-03 Thread Franco Martelli
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 re

Re: tree with dir size

2024-06-01 Thread Lee
On Fri, May 31, 2024 at 11:18 PM Greg Wooledge wrote: > > On Fri, May 31, 2024 at 09:35:59PM -0500, David Wright wrote: > > If a coloured ] is unimportant, I suppose you could use: > > > > tree --du -Fh whatever | grep --color '][[:space:]][[:space:]].*/$' > > You don't need to count spaces. Jus

Re: tree with dir size

2024-05-31 Thread Greg Wooledge
On Fri, May 31, 2024 at 09:35:59PM -0500, David Wright wrote: > If a coloured ] is unimportant, I suppose you could use: > > tree --du -Fh whatever | grep --color '][[:space:]][[:space:]].*/$' You don't need to count spaces. Just '].*/$' would suffice. We already know we want to start with th

Re: tree with dir size

2024-05-31 Thread David Wright
On Fri 31 May 2024 at 16:03:22 (-0400), Greg Wooledge wrote: > On Fri, May 31, 2024 at 09:18:03PM +0200, Franco Martelli wrote: > > On 31/05/24 at 02:18, Greg Wooledge wrote: > > > Confusing and useless. I still don't have a better answer than this: > > > > > > hobbit:~$ tree --du -Fh /tmp/x | gr

Re: tree with dir size

2024-05-31 Thread Greg Wooledge
On Fri, May 31, 2024 at 09:18:03PM +0200, Franco Martelli wrote: > On 31/05/24 at 02:18, Greg Wooledge wrote: > > Confusing and useless. I still don't have a better answer than this: > > > > hobbit:~$ tree --du -Fh /tmp/x | grep /$ > > [7.8M]/tmp/x/ > > └── [4.0K] y/ > > It could be improved ad

Re: tree with dir size

2024-05-31 Thread Franco Martelli
On 31/05/24 at 02:18, Greg Wooledge wrote: Confusing and useless. I still don't have a better answer than this: hobbit:~$ tree --du -Fh /tmp/x | grep /$ [7.8M]/tmp/x/ └── [4.0K] y/ It could be improved adding the "-a" switch to show also the hidden directories and the "--color" switch to th

Re: tree with dir size

2024-05-30 Thread Felix Miata
Northwind composed on 2024-05-31 06:28 (UTC+0800): > is there a command that shows dir/subdir structure like `tree`, but for > each dir has the size in results as well? Is ncdu any use to your need? -- Evolution as taught in public schools is, like religion, based on faith, not based on

Re: tree with dir size

2024-05-30 Thread Greg Wooledge
On Thu, May 30, 2024 at 08:04:26PM -0400, e...@gmx.us wrote: > > > It looks like "tree --du" should do it, but "tree -d --du -h" says > > > ├── [452K] Documents > I think "du -h -S -s Documents/" gives just the files in Documents, and not > its subdirectories, and it gives 269M. "ls -ldh Document

Re: tree with dir size

2024-05-30 Thread eben
On 5/30/24 18:54, Greg Wooledge wrote: On Thu, May 30, 2024 at 06:51:30PM -0400, e...@gmx.us wrote: It looks like "tree --du" should do it, but "tree -d --du -h" says ├── [452K] Documents when du says it's 787M. Well, that sounds like one of the numbers includes subdirectories and the other

Re: tree with dir size

2024-05-30 Thread Greg Wooledge
On Fri, May 31, 2024 at 06:57:27AM +0800, Northwind wrote: > both the size of current path and subdir should be expected. According to the man page, that's what it does. I just installed tree and tried it. There's a subtle behavior that I did not expect: hobbit:/usr/local$ tree -d --du -h [3.9M

Re: tree with dir size

2024-05-30 Thread Northwind
both the size of current path and subdir should be expected. thanks. The question is: which one do you want?

Re: tree with dir size

2024-05-30 Thread Greg Wooledge
On Thu, May 30, 2024 at 06:51:30PM -0400, e...@gmx.us wrote: > It looks like "tree --du" should do it, but "tree -d --du -h" says > > ├── [452K] Documents > > when du says it's 787M. Well, that sounds like one of the numbers includes subdirectories and the other only includes files in the immed

Re: tree with dir size

2024-05-30 Thread eben
On 5/30/24 18:28, Northwind wrote: Hello, is there a command that shows dir/subdir structure like `tree`, but for each dir has the size in results as well? It looks like "tree --du" should do it, but "tree -d --du -h" says ├── [452K] Documents when du says it's 787M. -- When we've nuked th

tree with dir size

2024-05-30 Thread Northwind
Hello, is there a command that shows dir/subdir structure like `tree`, but for each dir has the size in results as well? Thanks.