graphical representation of `du`
Chris Rees
utisoft at gmail.com
Sat Apr 2 16:15:35 UTC 2011
On 2 April 2011 15:20, Ryan Coleman <editor at d3photography.com> wrote:
> I found this command:
> ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
>
> Which makes this:
> |-Mar17
> |---1300074369-chow
> |-----download
> |-------small
> |---1300421616-Cunningham
> |-----download
> |-------small
>
> But I want to use `du` instead to convert this
> 2.0M ./Mar17/1300074369-chow/download/small
> 2.0M ./Mar17/1300074369-chow/download
> 2.0M ./Mar17/1300074369-chow
> 2.1M ./Mar17/1300421616-Cunningham/download/small
> 2.1M ./Mar17/1300421616-Cunningham/download
> 2.1M ./Mar17/1300421616-Cunningham
> 4.1M ./Mar17
>
> into this:
> |-Mar17 [4.3M]
> |---1300074369-chow [2.0M]
> |-----download [2.0M]
> |-------small [2.0M]
> |---1300421616-Cunningham [2.1M]
> |-----download [2.1M]
> |-------small [2.1M]
>
>
> I realize it does it backwards and I can live with that... OR mix the two to run the first command and run another command to get the folders total size or something... you know?
>
du -h . | awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' |
awk '{print($2" ["$1"]");}' | sed -e 's,[^-][^/]*/,--,g' -e 's,^,|,'
Does it forwards :P
[crees at zeus]~/workspace/ports% du -h . | awk '{a[i++]=$0} END {for
(j=i-1; j>=0;) 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 at zeus]~/workspace/ports%
Any refinements requested I'll have a look at.
Chris
More information about the freebsd-questions
mailing list