combine the best of 'du' and 'tree'
Clash Royale CLAN TAG#URR8PPP
up vote
15
down vote
favorite
I'm wondering if we can combine the honesty of 'du' with the indented formatting of 'tree'. If I want a listing of the sizes of directories:
du -hx -d2
...displays two levels deep and all the size summaries are honest, but there's no indenting of subdirs. On the other hand:
tree --du -shaC -L 2
...indents and colorizes nicely however the reported sizes are a lie. To get the real sizes one must:
tree --du -shaC
...which is to say that you only get the true sizes if you let 'tree' show you the entire directory structure. I'd like to be able to always have correct size summaries regardless of how many levels of subdirs I want to actually display. I often do this:
tree -du -shaC | grep "[01;34m"
... which prunes out everything but directories, and indents them nicely ... but there's no easy way to limit the display to just a given number levels (without the summaries lying). Is there a way? Perhaps I've missed the correct switches ...
disk-usage tree
add a comment |Â
up vote
15
down vote
favorite
I'm wondering if we can combine the honesty of 'du' with the indented formatting of 'tree'. If I want a listing of the sizes of directories:
du -hx -d2
...displays two levels deep and all the size summaries are honest, but there's no indenting of subdirs. On the other hand:
tree --du -shaC -L 2
...indents and colorizes nicely however the reported sizes are a lie. To get the real sizes one must:
tree --du -shaC
...which is to say that you only get the true sizes if you let 'tree' show you the entire directory structure. I'd like to be able to always have correct size summaries regardless of how many levels of subdirs I want to actually display. I often do this:
tree -du -shaC | grep "[01;34m"
... which prunes out everything but directories, and indents them nicely ... but there's no easy way to limit the display to just a given number levels (without the summaries lying). Is there a way? Perhaps I've missed the correct switches ...
disk-usage tree
add a comment |Â
up vote
15
down vote
favorite
up vote
15
down vote
favorite
I'm wondering if we can combine the honesty of 'du' with the indented formatting of 'tree'. If I want a listing of the sizes of directories:
du -hx -d2
...displays two levels deep and all the size summaries are honest, but there's no indenting of subdirs. On the other hand:
tree --du -shaC -L 2
...indents and colorizes nicely however the reported sizes are a lie. To get the real sizes one must:
tree --du -shaC
...which is to say that you only get the true sizes if you let 'tree' show you the entire directory structure. I'd like to be able to always have correct size summaries regardless of how many levels of subdirs I want to actually display. I often do this:
tree -du -shaC | grep "[01;34m"
... which prunes out everything but directories, and indents them nicely ... but there's no easy way to limit the display to just a given number levels (without the summaries lying). Is there a way? Perhaps I've missed the correct switches ...
disk-usage tree
I'm wondering if we can combine the honesty of 'du' with the indented formatting of 'tree'. If I want a listing of the sizes of directories:
du -hx -d2
...displays two levels deep and all the size summaries are honest, but there's no indenting of subdirs. On the other hand:
tree --du -shaC -L 2
...indents and colorizes nicely however the reported sizes are a lie. To get the real sizes one must:
tree --du -shaC
...which is to say that you only get the true sizes if you let 'tree' show you the entire directory structure. I'd like to be able to always have correct size summaries regardless of how many levels of subdirs I want to actually display. I often do this:
tree -du -shaC | grep "[01;34m"
... which prunes out everything but directories, and indents them nicely ... but there's no easy way to limit the display to just a given number levels (without the summaries lying). Is there a way? Perhaps I've missed the correct switches ...
disk-usage tree
disk-usage tree
edited Oct 25 '15 at 1:55
terdonâ¦
125k29236415
125k29236415
asked Oct 25 '15 at 1:39
Ray Andrews
7203824
7203824
add a comment |Â
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
5
down vote
accepted
Also checkout ncdu:
http://dev.yorhel.nl/ncdu
Its page also lists other "similar projects":
gt5 - Quite similar to ncdu, but a different approach.
tdu - Another small ncurses-based disk usage visualization utility.
TreeSize - GTK, using a treeview.
Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.
GdMap - GTK, with a treemap display.
Filelight - KDE, using pie-charts.
KDirStat - KDE, with a treemap display.
QDiskUsage - Qt, using pie-charts.
xdiskusage - FLTK, with a treemap display.
fsv - 3D visualization.
Philesight - Web-based clone of Filelight.
1
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
add a comment |Â
up vote
8
down vote
You don't need to grep for the colour code, the -d
option is list directories only
.
This seems to do what you want:
$ tree --du -d -shaC | grep -Ev '( *[^ ]* )2['
.
âÂÂâÂÂâ [ 18] dir1
âÂÂâÂÂâ [ 30] dir2
âÂÂâÂÂâ [ 205] junk
âÂÂààâÂÂâÂÂâ [ 18] dir1
âÂÂààâÂÂâÂÂâ [ 30] dir2
âÂÂààâÂÂâÂÂâ [ 76] dir3
âÂÂâÂÂâ [ 119] merge
âÂÂâÂÂâ [ 20] stuff
4.4K used in 10 directories
The grep
command removes all lines that have (one or more spaces followed by a non-space followed by a space) twice, followed by a [
.
If you want a depth of 1, change the bound count inside the curly braces to 1
rather than 2
. same if you want a depth of 3, change it to 3
.
You can turn this into a shell function, like so:
mytreedu()
local depth=''
while getopts "L:" opt ; do
case "$opt" in
L) depth="$OPTARG" ;;
esac
done
shift "$((OPTIND-1))"
if [ -z "$depth" ] ; then
tree --du -d -shaC "$@"
else
local PATTERN='( *[^ ]* )'"$depth"'['
tree --du -d -shaC "$@"
This uses getopts
to "steal" any -L
option and its argument from the tree
command line, if there is one. If there isn't a -L n
option on the command line, then that works too.
All other options and args are passed to the tree
command.
The local PATTERN=...
line isn't really necessary. I only did it like that to make sure that it would fit on one line and not word-wrap here on U&L
. The regular expression could and probably should just go directly on the tree | grep ...
line.
Run it like this:
mytreedu
or
mytreedu -L 2 /path/to/dir/
1
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
you only mentioned-L
as being a problem, didn't mention-d
at all. Now that I look more closely at the numbers reported, neithertree --du
nortree --du -d
report sizes that in any way resemble those reported bydu
.
â cas
Oct 25 '15 at 19:47
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
tree --du
doesn't seem to give correct sizes for directories anyway, with or without-d
or-L
. I have no idea what the numbers are supposed to be, but they're unrelated to whatdu
reports.
â cas
Oct 26 '15 at 0:30
add a comment |Â
up vote
0
down vote
Inspired by cas, I'm now doing this:
treee ()
integer levels=$(( ($1 + 1) * 4 ))
tree --du -shaC
if you're going to throw away all the getopts stuff, you should at least still have"$@"
immediately after the-shaC
. otherwise that function is hard-coded to work for the current directory only.
â cas
Oct 25 '15 at 19:50
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
One of the benefits of usinggetopts
is that options can appear in any order on the command line. The initial version of themytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtingetopts
to process the-L
option. This allowed the-L n
option to appear anywhere on the command line. It also allowed it to be completely optional.
â cas
Oct 26 '15 at 0:24
another way of looking at it is thatgetopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use thegetopt
program (note that's without ans
) from theutil-linux
package you can use both short single-letter options (e.g.-l
) and long options (like--long
) just like GNU programs.
â cas
Oct 26 '15 at 0:26
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
add a comment |Â
up vote
0
down vote
You can use dutree
- coloured output, according to the LS_COLORS environment variable.
- display the file system tree
- ability to aggregate small files
- ability to exclude files or directories
- ability to compare different directories
- fast, written in Rust
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Also checkout ncdu:
http://dev.yorhel.nl/ncdu
Its page also lists other "similar projects":
gt5 - Quite similar to ncdu, but a different approach.
tdu - Another small ncurses-based disk usage visualization utility.
TreeSize - GTK, using a treeview.
Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.
GdMap - GTK, with a treemap display.
Filelight - KDE, using pie-charts.
KDirStat - KDE, with a treemap display.
QDiskUsage - Qt, using pie-charts.
xdiskusage - FLTK, with a treemap display.
fsv - 3D visualization.
Philesight - Web-based clone of Filelight.
1
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
add a comment |Â
up vote
5
down vote
accepted
Also checkout ncdu:
http://dev.yorhel.nl/ncdu
Its page also lists other "similar projects":
gt5 - Quite similar to ncdu, but a different approach.
tdu - Another small ncurses-based disk usage visualization utility.
TreeSize - GTK, using a treeview.
Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.
GdMap - GTK, with a treemap display.
Filelight - KDE, using pie-charts.
KDirStat - KDE, with a treemap display.
QDiskUsage - Qt, using pie-charts.
xdiskusage - FLTK, with a treemap display.
fsv - 3D visualization.
Philesight - Web-based clone of Filelight.
1
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Also checkout ncdu:
http://dev.yorhel.nl/ncdu
Its page also lists other "similar projects":
gt5 - Quite similar to ncdu, but a different approach.
tdu - Another small ncurses-based disk usage visualization utility.
TreeSize - GTK, using a treeview.
Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.
GdMap - GTK, with a treemap display.
Filelight - KDE, using pie-charts.
KDirStat - KDE, with a treemap display.
QDiskUsage - Qt, using pie-charts.
xdiskusage - FLTK, with a treemap display.
fsv - 3D visualization.
Philesight - Web-based clone of Filelight.
Also checkout ncdu:
http://dev.yorhel.nl/ncdu
Its page also lists other "similar projects":
gt5 - Quite similar to ncdu, but a different approach.
tdu - Another small ncurses-based disk usage visualization utility.
TreeSize - GTK, using a treeview.
Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.
GdMap - GTK, with a treemap display.
Filelight - KDE, using pie-charts.
KDirStat - KDE, with a treemap display.
QDiskUsage - Qt, using pie-charts.
xdiskusage - FLTK, with a treemap display.
fsv - 3D visualization.
Philesight - Web-based clone of Filelight.
answered Nov 3 '15 at 23:47
David PotoÃÂnik
663
663
1
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
add a comment |Â
1
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
1
1
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
Thanks David, finally got around to looking at those. I picked ncdu.
â Ray Andrews
Nov 18 '15 at 1:20
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@David where does tdu come from ?
â shirish
Jan 27 '17 at 21:10
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
@shirish Refer to my source, noted above
â David PotoÃÂnik
Mar 30 '17 at 16:49
add a comment |Â
up vote
8
down vote
You don't need to grep for the colour code, the -d
option is list directories only
.
This seems to do what you want:
$ tree --du -d -shaC | grep -Ev '( *[^ ]* )2['
.
âÂÂâÂÂâ [ 18] dir1
âÂÂâÂÂâ [ 30] dir2
âÂÂâÂÂâ [ 205] junk
âÂÂààâÂÂâÂÂâ [ 18] dir1
âÂÂààâÂÂâÂÂâ [ 30] dir2
âÂÂààâÂÂâÂÂâ [ 76] dir3
âÂÂâÂÂâ [ 119] merge
âÂÂâÂÂâ [ 20] stuff
4.4K used in 10 directories
The grep
command removes all lines that have (one or more spaces followed by a non-space followed by a space) twice, followed by a [
.
If you want a depth of 1, change the bound count inside the curly braces to 1
rather than 2
. same if you want a depth of 3, change it to 3
.
You can turn this into a shell function, like so:
mytreedu()
local depth=''
while getopts "L:" opt ; do
case "$opt" in
L) depth="$OPTARG" ;;
esac
done
shift "$((OPTIND-1))"
if [ -z "$depth" ] ; then
tree --du -d -shaC "$@"
else
local PATTERN='( *[^ ]* )'"$depth"'['
tree --du -d -shaC "$@"
This uses getopts
to "steal" any -L
option and its argument from the tree
command line, if there is one. If there isn't a -L n
option on the command line, then that works too.
All other options and args are passed to the tree
command.
The local PATTERN=...
line isn't really necessary. I only did it like that to make sure that it would fit on one line and not word-wrap here on U&L
. The regular expression could and probably should just go directly on the tree | grep ...
line.
Run it like this:
mytreedu
or
mytreedu -L 2 /path/to/dir/
1
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
you only mentioned-L
as being a problem, didn't mention-d
at all. Now that I look more closely at the numbers reported, neithertree --du
nortree --du -d
report sizes that in any way resemble those reported bydu
.
â cas
Oct 25 '15 at 19:47
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
tree --du
doesn't seem to give correct sizes for directories anyway, with or without-d
or-L
. I have no idea what the numbers are supposed to be, but they're unrelated to whatdu
reports.
â cas
Oct 26 '15 at 0:30
add a comment |Â
up vote
8
down vote
You don't need to grep for the colour code, the -d
option is list directories only
.
This seems to do what you want:
$ tree --du -d -shaC | grep -Ev '( *[^ ]* )2['
.
âÂÂâÂÂâ [ 18] dir1
âÂÂâÂÂâ [ 30] dir2
âÂÂâÂÂâ [ 205] junk
âÂÂààâÂÂâÂÂâ [ 18] dir1
âÂÂààâÂÂâÂÂâ [ 30] dir2
âÂÂààâÂÂâÂÂâ [ 76] dir3
âÂÂâÂÂâ [ 119] merge
âÂÂâÂÂâ [ 20] stuff
4.4K used in 10 directories
The grep
command removes all lines that have (one or more spaces followed by a non-space followed by a space) twice, followed by a [
.
If you want a depth of 1, change the bound count inside the curly braces to 1
rather than 2
. same if you want a depth of 3, change it to 3
.
You can turn this into a shell function, like so:
mytreedu()
local depth=''
while getopts "L:" opt ; do
case "$opt" in
L) depth="$OPTARG" ;;
esac
done
shift "$((OPTIND-1))"
if [ -z "$depth" ] ; then
tree --du -d -shaC "$@"
else
local PATTERN='( *[^ ]* )'"$depth"'['
tree --du -d -shaC "$@"
This uses getopts
to "steal" any -L
option and its argument from the tree
command line, if there is one. If there isn't a -L n
option on the command line, then that works too.
All other options and args are passed to the tree
command.
The local PATTERN=...
line isn't really necessary. I only did it like that to make sure that it would fit on one line and not word-wrap here on U&L
. The regular expression could and probably should just go directly on the tree | grep ...
line.
Run it like this:
mytreedu
or
mytreedu -L 2 /path/to/dir/
1
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
you only mentioned-L
as being a problem, didn't mention-d
at all. Now that I look more closely at the numbers reported, neithertree --du
nortree --du -d
report sizes that in any way resemble those reported bydu
.
â cas
Oct 25 '15 at 19:47
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
tree --du
doesn't seem to give correct sizes for directories anyway, with or without-d
or-L
. I have no idea what the numbers are supposed to be, but they're unrelated to whatdu
reports.
â cas
Oct 26 '15 at 0:30
add a comment |Â
up vote
8
down vote
up vote
8
down vote
You don't need to grep for the colour code, the -d
option is list directories only
.
This seems to do what you want:
$ tree --du -d -shaC | grep -Ev '( *[^ ]* )2['
.
âÂÂâÂÂâ [ 18] dir1
âÂÂâÂÂâ [ 30] dir2
âÂÂâÂÂâ [ 205] junk
âÂÂààâÂÂâÂÂâ [ 18] dir1
âÂÂààâÂÂâÂÂâ [ 30] dir2
âÂÂààâÂÂâÂÂâ [ 76] dir3
âÂÂâÂÂâ [ 119] merge
âÂÂâÂÂâ [ 20] stuff
4.4K used in 10 directories
The grep
command removes all lines that have (one or more spaces followed by a non-space followed by a space) twice, followed by a [
.
If you want a depth of 1, change the bound count inside the curly braces to 1
rather than 2
. same if you want a depth of 3, change it to 3
.
You can turn this into a shell function, like so:
mytreedu()
local depth=''
while getopts "L:" opt ; do
case "$opt" in
L) depth="$OPTARG" ;;
esac
done
shift "$((OPTIND-1))"
if [ -z "$depth" ] ; then
tree --du -d -shaC "$@"
else
local PATTERN='( *[^ ]* )'"$depth"'['
tree --du -d -shaC "$@"
This uses getopts
to "steal" any -L
option and its argument from the tree
command line, if there is one. If there isn't a -L n
option on the command line, then that works too.
All other options and args are passed to the tree
command.
The local PATTERN=...
line isn't really necessary. I only did it like that to make sure that it would fit on one line and not word-wrap here on U&L
. The regular expression could and probably should just go directly on the tree | grep ...
line.
Run it like this:
mytreedu
or
mytreedu -L 2 /path/to/dir/
You don't need to grep for the colour code, the -d
option is list directories only
.
This seems to do what you want:
$ tree --du -d -shaC | grep -Ev '( *[^ ]* )2['
.
âÂÂâÂÂâ [ 18] dir1
âÂÂâÂÂâ [ 30] dir2
âÂÂâÂÂâ [ 205] junk
âÂÂààâÂÂâÂÂâ [ 18] dir1
âÂÂààâÂÂâÂÂâ [ 30] dir2
âÂÂààâÂÂâÂÂâ [ 76] dir3
âÂÂâÂÂâ [ 119] merge
âÂÂâÂÂâ [ 20] stuff
4.4K used in 10 directories
The grep
command removes all lines that have (one or more spaces followed by a non-space followed by a space) twice, followed by a [
.
If you want a depth of 1, change the bound count inside the curly braces to 1
rather than 2
. same if you want a depth of 3, change it to 3
.
You can turn this into a shell function, like so:
mytreedu()
local depth=''
while getopts "L:" opt ; do
case "$opt" in
L) depth="$OPTARG" ;;
esac
done
shift "$((OPTIND-1))"
if [ -z "$depth" ] ; then
tree --du -d -shaC "$@"
else
local PATTERN='( *[^ ]* )'"$depth"'['
tree --du -d -shaC "$@"
This uses getopts
to "steal" any -L
option and its argument from the tree
command line, if there is one. If there isn't a -L n
option on the command line, then that works too.
All other options and args are passed to the tree
command.
The local PATTERN=...
line isn't really necessary. I only did it like that to make sure that it would fit on one line and not word-wrap here on U&L
. The regular expression could and probably should just go directly on the tree | grep ...
line.
Run it like this:
mytreedu
or
mytreedu -L 2 /path/to/dir/
edited Oct 25 '15 at 12:54
terdonâ¦
125k29236415
125k29236415
answered Oct 25 '15 at 2:21
cas
38.1k44796
38.1k44796
1
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
you only mentioned-L
as being a problem, didn't mention-d
at all. Now that I look more closely at the numbers reported, neithertree --du
nortree --du -d
report sizes that in any way resemble those reported bydu
.
â cas
Oct 25 '15 at 19:47
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
tree --du
doesn't seem to give correct sizes for directories anyway, with or without-d
or-L
. I have no idea what the numbers are supposed to be, but they're unrelated to whatdu
reports.
â cas
Oct 26 '15 at 0:30
add a comment |Â
1
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
you only mentioned-L
as being a problem, didn't mention-d
at all. Now that I look more closely at the numbers reported, neithertree --du
nortree --du -d
report sizes that in any way resemble those reported bydu
.
â cas
Oct 25 '15 at 19:47
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
tree --du
doesn't seem to give correct sizes for directories anyway, with or without-d
or-L
. I have no idea what the numbers are supposed to be, but they're unrelated to whatdu
reports.
â cas
Oct 26 '15 at 0:30
1
1
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
I love the code, but repeat that you can't use the '-d' because if you do, the size summaries are incorrect, or at least they are here. The size will be reported always as '4096' which is the size of the entry for the dir itself, but not the size of all it's contents.
â Ray Andrews
Oct 25 '15 at 15:41
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
... should have said '4096' for each directory under the current directory ... but you don't get the sizes of the dir including it's files.
â Ray Andrews
Oct 25 '15 at 15:48
you only mentioned
-L
as being a problem, didn't mention -d
at all. Now that I look more closely at the numbers reported, neither tree --du
nor tree --du -d
report sizes that in any way resemble those reported by du
.â cas
Oct 25 '15 at 19:47
you only mentioned
-L
as being a problem, didn't mention -d
at all. Now that I look more closely at the numbers reported, neither tree --du
nor tree --du -d
report sizes that in any way resemble those reported by du
.â cas
Oct 25 '15 at 19:47
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
Point being that anything less than a 100% display will not give you correct sizes. You could limit via '-d' or '-L 2' or whatever else--it it isn't shown, it isn't counted in the size.
â Ray Andrews
Oct 26 '15 at 0:17
tree --du
doesn't seem to give correct sizes for directories anyway, with or without -d
or -L
. I have no idea what the numbers are supposed to be, but they're unrelated to what du
reports.â cas
Oct 26 '15 at 0:30
tree --du
doesn't seem to give correct sizes for directories anyway, with or without -d
or -L
. I have no idea what the numbers are supposed to be, but they're unrelated to what du
reports.â cas
Oct 26 '15 at 0:30
add a comment |Â
up vote
0
down vote
Inspired by cas, I'm now doing this:
treee ()
integer levels=$(( ($1 + 1) * 4 ))
tree --du -shaC
if you're going to throw away all the getopts stuff, you should at least still have"$@"
immediately after the-shaC
. otherwise that function is hard-coded to work for the current directory only.
â cas
Oct 25 '15 at 19:50
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
One of the benefits of usinggetopts
is that options can appear in any order on the command line. The initial version of themytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtingetopts
to process the-L
option. This allowed the-L n
option to appear anywhere on the command line. It also allowed it to be completely optional.
â cas
Oct 26 '15 at 0:24
another way of looking at it is thatgetopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use thegetopt
program (note that's without ans
) from theutil-linux
package you can use both short single-letter options (e.g.-l
) and long options (like--long
) just like GNU programs.
â cas
Oct 26 '15 at 0:26
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
add a comment |Â
up vote
0
down vote
Inspired by cas, I'm now doing this:
treee ()
integer levels=$(( ($1 + 1) * 4 ))
tree --du -shaC
if you're going to throw away all the getopts stuff, you should at least still have"$@"
immediately after the-shaC
. otherwise that function is hard-coded to work for the current directory only.
â cas
Oct 25 '15 at 19:50
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
One of the benefits of usinggetopts
is that options can appear in any order on the command line. The initial version of themytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtingetopts
to process the-L
option. This allowed the-L n
option to appear anywhere on the command line. It also allowed it to be completely optional.
â cas
Oct 26 '15 at 0:24
another way of looking at it is thatgetopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use thegetopt
program (note that's without ans
) from theutil-linux
package you can use both short single-letter options (e.g.-l
) and long options (like--long
) just like GNU programs.
â cas
Oct 26 '15 at 0:26
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Inspired by cas, I'm now doing this:
treee ()
integer levels=$(( ($1 + 1) * 4 ))
tree --du -shaC
Inspired by cas, I'm now doing this:
treee ()
integer levels=$(( ($1 + 1) * 4 ))
tree --du -shaC
answered Oct 25 '15 at 17:13
Ray Andrews
7203824
7203824
if you're going to throw away all the getopts stuff, you should at least still have"$@"
immediately after the-shaC
. otherwise that function is hard-coded to work for the current directory only.
â cas
Oct 25 '15 at 19:50
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
One of the benefits of usinggetopts
is that options can appear in any order on the command line. The initial version of themytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtingetopts
to process the-L
option. This allowed the-L n
option to appear anywhere on the command line. It also allowed it to be completely optional.
â cas
Oct 26 '15 at 0:24
another way of looking at it is thatgetopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use thegetopt
program (note that's without ans
) from theutil-linux
package you can use both short single-letter options (e.g.-l
) and long options (like--long
) just like GNU programs.
â cas
Oct 26 '15 at 0:26
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
add a comment |Â
if you're going to throw away all the getopts stuff, you should at least still have"$@"
immediately after the-shaC
. otherwise that function is hard-coded to work for the current directory only.
â cas
Oct 25 '15 at 19:50
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
One of the benefits of usinggetopts
is that options can appear in any order on the command line. The initial version of themytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtingetopts
to process the-L
option. This allowed the-L n
option to appear anywhere on the command line. It also allowed it to be completely optional.
â cas
Oct 26 '15 at 0:24
another way of looking at it is thatgetopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use thegetopt
program (note that's without ans
) from theutil-linux
package you can use both short single-letter options (e.g.-l
) and long options (like--long
) just like GNU programs.
â cas
Oct 26 '15 at 0:26
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
if you're going to throw away all the getopts stuff, you should at least still have
"$@"
immediately after the -shaC
. otherwise that function is hard-coded to work for the current directory only.â cas
Oct 25 '15 at 19:50
if you're going to throw away all the getopts stuff, you should at least still have
"$@"
immediately after the -shaC
. otherwise that function is hard-coded to work for the current directory only.â cas
Oct 25 '15 at 19:50
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
Once we got the thing working, I was going to ask you about that: please elaborate. Right about "$@" of course, but so far I only ever use it in the current dir, so haven't noticed that yet. All this 'getopts' stuff is new to me, I'd like to know what you are thinking there.
â Ray Andrews
Oct 26 '15 at 0:14
One of the benefits of using
getopts
is that options can appear in any order on the command line. The initial version of the mytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtin getopts
to process the -L
option. This allowed the -L n
option to appear anywhere on the command line. It also allowed it to be completely optional.â cas
Oct 26 '15 at 0:24
One of the benefits of using
getopts
is that options can appear in any order on the command line. The initial version of the mytree
function I wrote used "$1" just as yours did, so the depth argument had to be the first argument, and it was not optional. I decided that wasn't good enough so used the bash-builtin getopts
to process the -L
option. This allowed the -L n
option to appear anywhere on the command line. It also allowed it to be completely optional.â cas
Oct 26 '15 at 0:24
another way of looking at it is that
getopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use the getopt
program (note that's without an s
) from the util-linux
package you can use both short single-letter options (e.g. -l
) and long options (like --long
) just like GNU programs.â cas
Oct 26 '15 at 0:26
another way of looking at it is that
getopts
allows you to write scripts that take real options and arguments (rather than just args in hard-coded positions like $1 $2 $3 etc), just like most other programs on your system. And if you use the getopt
program (note that's without an s
) from the util-linux
package you can use both short single-letter options (e.g. -l
) and long options (like --long
) just like GNU programs.â cas
Oct 26 '15 at 0:26
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
Ah ... it comes back to me now. Yes, I actually used that once. Must take another look at it. Thanks.
â Ray Andrews
Oct 26 '15 at 6:54
add a comment |Â
up vote
0
down vote
You can use dutree
- coloured output, according to the LS_COLORS environment variable.
- display the file system tree
- ability to aggregate small files
- ability to exclude files or directories
- ability to compare different directories
- fast, written in Rust
add a comment |Â
up vote
0
down vote
You can use dutree
- coloured output, according to the LS_COLORS environment variable.
- display the file system tree
- ability to aggregate small files
- ability to exclude files or directories
- ability to compare different directories
- fast, written in Rust
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can use dutree
- coloured output, according to the LS_COLORS environment variable.
- display the file system tree
- ability to aggregate small files
- ability to exclude files or directories
- ability to compare different directories
- fast, written in Rust
You can use dutree
- coloured output, according to the LS_COLORS environment variable.
- display the file system tree
- ability to aggregate small files
- ability to exclude files or directories
- ability to compare different directories
- fast, written in Rust
answered 7 mins ago
nachoparker
44935
44935
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f238455%2fcombine-the-best-of-du-and-tree%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password