Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Apr 2011 17:15:04 +0100
From:      Chris Rees <utisoft@gmail.com>
To:        Ryan Coleman <editor@d3photography.com>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: graphical representation of `du`
Message-ID:  <BANLkTi=trnnEEW6ELSV5JRnW5erm490sTA@mail.gmail.com>
In-Reply-To: <0DD2BF5C-7387-4AFA-BF43-B1683F3773E8@d3photography.com>
References:  <0DD2BF5C-7387-4AFA-BF43-B1683F3773E8@d3photography.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2 April 2011 15:20, Ryan Coleman <editor@d3photography.com> wrote:
> I found this command:
> ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ =A0=
 /' -e 's/-/|/'
>
> Which makes this:
> =A0 |-Mar17
> =A0 |---1300074369-chow
> =A0 |-----download
> =A0 |-------small
> =A0 |---1300421616-Cunningham
> =A0 |-----download
> =A0 |-------small
>
> But I want to use `du` instead to convert this
> 2.0M =A0 =A0./Mar17/1300074369-chow/download/small
> 2.0M =A0 =A0./Mar17/1300074369-chow/download
> 2.0M =A0 =A0./Mar17/1300074369-chow
> 2.1M =A0 =A0./Mar17/1300421616-Cunningham/download/small
> 2.1M =A0 =A0./Mar17/1300421616-Cunningham/download
> 2.1M =A0 =A0./Mar17/1300421616-Cunningham
> 4.1M =A0 =A0./Mar17
>
> into this:
> =A0 |-Mar17 [4.3M]
> =A0 |---1300074369-chow [2.0M]
> =A0 |-----download [2.0M]
> =A0 |-------small [2.0M]
> =A0 |---1300421616-Cunningham [2.1M]
> =A0 |-----download [2.1M]
> =A0 |-------small [2.1M]
>
>
> I realize it does it backwards and I can live with that... =A0OR mix the =
two to run the first command and run another command to get the folders tot=
al size or something... you know?
>

du -h . | awk '{a[i++]=3D$0} END {for (j=3Di-1; j>=3D0;) print a[j--] }' |
awk '{print($2" ["$1"]");}' | sed -e 's,[^-][^/]*/,--,g' -e 's,^,|,'

Does it forwards :P

[crees@zeus]~/workspace/ports% du -h . | awk '{a[i++]=3D$0} END {for
(j=3Di-1; j>=3D0;) print a[j--] }' | awk '{print($2" ["$1"]");}' | sed -e
's,[^-][^/]*/,--,g' -e 's,^,|,'
|. [445K]
|--net-mgmt [81K]
|----CVS [5.5K]
|----zabbix-server [74K]
|------files [11K]
|--------CVS [4.5K]
|------CVS [4.5K]
... etc...
|--net [31K]
|----pppoa [24K]
|------CVS [4.5K]
|------files [12K]
|--------CVS [4.5K]
|----CVS [5.5K]
[crees@zeus]~/workspace/ports%

Any refinements requested I'll have a look at.

Chris



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTi=trnnEEW6ELSV5JRnW5erm490sTA>