Is there any du (disk usage) command flag that summarizes the size for each sub-directory
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I have the following directory structure (example) -
main
|--src
|--com
|- company
|--org
|- apache
|--resources
|--abc
|--etc
I need the disk space used by each sub-directory under the main
directory. So, the output would be something like -
user@main> du -command_switches
1M src
20M resources
3M etc
I have tried several switches available - sh, Sh, ash, aSH - but I could not get the required result.
Any suggestions in this direction would really help.
linux command-line
add a comment |Â
up vote
4
down vote
favorite
I have the following directory structure (example) -
main
|--src
|--com
|- company
|--org
|- apache
|--resources
|--abc
|--etc
I need the disk space used by each sub-directory under the main
directory. So, the output would be something like -
user@main> du -command_switches
1M src
20M resources
3M etc
I have tried several switches available - sh, Sh, ash, aSH - but I could not get the required result.
Any suggestions in this direction would really help.
linux command-line
2
If you don't need that information put it a file or something like that, you could tryncdu
which shows what you need in an interactive TUI environment.
â Mioriin
Apr 27 at 13:26
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I have the following directory structure (example) -
main
|--src
|--com
|- company
|--org
|- apache
|--resources
|--abc
|--etc
I need the disk space used by each sub-directory under the main
directory. So, the output would be something like -
user@main> du -command_switches
1M src
20M resources
3M etc
I have tried several switches available - sh, Sh, ash, aSH - but I could not get the required result.
Any suggestions in this direction would really help.
linux command-line
I have the following directory structure (example) -
main
|--src
|--com
|- company
|--org
|- apache
|--resources
|--abc
|--etc
I need the disk space used by each sub-directory under the main
directory. So, the output would be something like -
user@main> du -command_switches
1M src
20M resources
3M etc
I have tried several switches available - sh, Sh, ash, aSH - but I could not get the required result.
Any suggestions in this direction would really help.
linux command-line
edited Apr 27 at 9:23
muru
33.2k576140
33.2k576140
asked Apr 27 at 9:19
Rakesh N
1235
1235
2
If you don't need that information put it a file or something like that, you could tryncdu
which shows what you need in an interactive TUI environment.
â Mioriin
Apr 27 at 13:26
add a comment |Â
2
If you don't need that information put it a file or something like that, you could tryncdu
which shows what you need in an interactive TUI environment.
â Mioriin
Apr 27 at 13:26
2
2
If you don't need that information put it a file or something like that, you could try
ncdu
which shows what you need in an interactive TUI environment.â Mioriin
Apr 27 at 13:26
If you don't need that information put it a file or something like that, you could try
ncdu
which shows what you need in an interactive TUI environment.â Mioriin
Apr 27 at 13:26
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
10
down vote
accepted
Some du
implementations support -d
ù to limit the depth at which disk usage is displayed (not at which disk usage is accounted), so du -hd 1 .
should work for the current directory.
Portably, you can always do:
find . ! -name . -prune -type d -exec du -s +
(add -h
if your du
implementation supports it)
Though note that if there are a lot of directories in the current directory, find
may end up running several invocations of du
which could mean that some hard links are counted several times. Some du
implementations also don't prevent hard links from being counted several times if they're encountered through the traversal of different arguments.
ù, with older versions of GNU du
, you may need --max-depth
instead. The -d
short option equivalent was only added in coreutils 8.8 for compatibility with FreeBSD
2
Alsodu -sh main/*
.
â Michael Homer
Apr 27 at 9:28
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could dodu -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
add a comment |Â
up vote
2
down vote
You may want to look into
$ du --max-depth=1 -h
I know this thread is about du
but you might also want to have a look at graphical applications, which can be more efficient at showing information like this, such as baobab or k4dirstat.
du -d
(aka--max-depth
in GNU du) is already mentioned in the accepted answer.
â Stéphane Chazelas
Apr 27 at 13:32
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
add a comment |Â
up vote
0
down vote
Maybe I'm missing what you're asking for, but I think
du -sh *
does exactly what you want. The *
is important here. With -s
, you get a summary for each directory on the command line, so with no explicit dir (implicit .
) you would just get a summary for everything, not the for each of the dirs under the top-level individually.
I tried this command. It does not include directories start with.
â Rakesh N
Apr 30 at 12:09
@RakeshN: If you want to include them you need either add extra patterns for them (.[!.]* ..?*
) or use the bash-specificshopt -s dotglob
to make*
match dotfiles.
â R..
Apr 30 at 16:11
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
Some du
implementations support -d
ù to limit the depth at which disk usage is displayed (not at which disk usage is accounted), so du -hd 1 .
should work for the current directory.
Portably, you can always do:
find . ! -name . -prune -type d -exec du -s +
(add -h
if your du
implementation supports it)
Though note that if there are a lot of directories in the current directory, find
may end up running several invocations of du
which could mean that some hard links are counted several times. Some du
implementations also don't prevent hard links from being counted several times if they're encountered through the traversal of different arguments.
ù, with older versions of GNU du
, you may need --max-depth
instead. The -d
short option equivalent was only added in coreutils 8.8 for compatibility with FreeBSD
2
Alsodu -sh main/*
.
â Michael Homer
Apr 27 at 9:28
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could dodu -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
add a comment |Â
up vote
10
down vote
accepted
Some du
implementations support -d
ù to limit the depth at which disk usage is displayed (not at which disk usage is accounted), so du -hd 1 .
should work for the current directory.
Portably, you can always do:
find . ! -name . -prune -type d -exec du -s +
(add -h
if your du
implementation supports it)
Though note that if there are a lot of directories in the current directory, find
may end up running several invocations of du
which could mean that some hard links are counted several times. Some du
implementations also don't prevent hard links from being counted several times if they're encountered through the traversal of different arguments.
ù, with older versions of GNU du
, you may need --max-depth
instead. The -d
short option equivalent was only added in coreutils 8.8 for compatibility with FreeBSD
2
Alsodu -sh main/*
.
â Michael Homer
Apr 27 at 9:28
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could dodu -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
add a comment |Â
up vote
10
down vote
accepted
up vote
10
down vote
accepted
Some du
implementations support -d
ù to limit the depth at which disk usage is displayed (not at which disk usage is accounted), so du -hd 1 .
should work for the current directory.
Portably, you can always do:
find . ! -name . -prune -type d -exec du -s +
(add -h
if your du
implementation supports it)
Though note that if there are a lot of directories in the current directory, find
may end up running several invocations of du
which could mean that some hard links are counted several times. Some du
implementations also don't prevent hard links from being counted several times if they're encountered through the traversal of different arguments.
ù, with older versions of GNU du
, you may need --max-depth
instead. The -d
short option equivalent was only added in coreutils 8.8 for compatibility with FreeBSD
Some du
implementations support -d
ù to limit the depth at which disk usage is displayed (not at which disk usage is accounted), so du -hd 1 .
should work for the current directory.
Portably, you can always do:
find . ! -name . -prune -type d -exec du -s +
(add -h
if your du
implementation supports it)
Though note that if there are a lot of directories in the current directory, find
may end up running several invocations of du
which could mean that some hard links are counted several times. Some du
implementations also don't prevent hard links from being counted several times if they're encountered through the traversal of different arguments.
ù, with older versions of GNU du
, you may need --max-depth
instead. The -d
short option equivalent was only added in coreutils 8.8 for compatibility with FreeBSD
edited Apr 29 at 22:27
Jeff Schaller
31.1k846105
31.1k846105
answered Apr 27 at 9:22
emmrk
17913
17913
2
Alsodu -sh main/*
.
â Michael Homer
Apr 27 at 9:28
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could dodu -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
add a comment |Â
2
Alsodu -sh main/*
.
â Michael Homer
Apr 27 at 9:28
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could dodu -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
2
2
Also
du -sh main/*
.â Michael Homer
Apr 27 at 9:28
Also
du -sh main/*
.â Michael Homer
Apr 27 at 9:28
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could do
du -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
@MichaelHomer, that would also report the disk usage of non-directory files and exclude hidden directory files. With zsh, you could do
du -sh main/*(D/)
â Stéphane Chazelas
Apr 27 at 9:46
add a comment |Â
up vote
2
down vote
You may want to look into
$ du --max-depth=1 -h
I know this thread is about du
but you might also want to have a look at graphical applications, which can be more efficient at showing information like this, such as baobab or k4dirstat.
du -d
(aka--max-depth
in GNU du) is already mentioned in the accepted answer.
â Stéphane Chazelas
Apr 27 at 13:32
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
add a comment |Â
up vote
2
down vote
You may want to look into
$ du --max-depth=1 -h
I know this thread is about du
but you might also want to have a look at graphical applications, which can be more efficient at showing information like this, such as baobab or k4dirstat.
du -d
(aka--max-depth
in GNU du) is already mentioned in the accepted answer.
â Stéphane Chazelas
Apr 27 at 13:32
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You may want to look into
$ du --max-depth=1 -h
I know this thread is about du
but you might also want to have a look at graphical applications, which can be more efficient at showing information like this, such as baobab or k4dirstat.
You may want to look into
$ du --max-depth=1 -h
I know this thread is about du
but you might also want to have a look at graphical applications, which can be more efficient at showing information like this, such as baobab or k4dirstat.
edited Apr 27 at 13:22
answered Apr 27 at 13:14
Francisco
1607
1607
du -d
(aka--max-depth
in GNU du) is already mentioned in the accepted answer.
â Stéphane Chazelas
Apr 27 at 13:32
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
add a comment |Â
du -d
(aka--max-depth
in GNU du) is already mentioned in the accepted answer.
â Stéphane Chazelas
Apr 27 at 13:32
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
du -d
(aka --max-depth
in GNU du) is already mentioned in the accepted answer.â Stéphane Chazelas
Apr 27 at 13:32
du -d
(aka --max-depth
in GNU du) is already mentioned in the accepted answer.â Stéphane Chazelas
Apr 27 at 13:32
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
@Francisco, the graphical tools sound interesting. I will give them a shot. Thanks.
â Rakesh N
Apr 27 at 14:17
add a comment |Â
up vote
0
down vote
Maybe I'm missing what you're asking for, but I think
du -sh *
does exactly what you want. The *
is important here. With -s
, you get a summary for each directory on the command line, so with no explicit dir (implicit .
) you would just get a summary for everything, not the for each of the dirs under the top-level individually.
I tried this command. It does not include directories start with.
â Rakesh N
Apr 30 at 12:09
@RakeshN: If you want to include them you need either add extra patterns for them (.[!.]* ..?*
) or use the bash-specificshopt -s dotglob
to make*
match dotfiles.
â R..
Apr 30 at 16:11
add a comment |Â
up vote
0
down vote
Maybe I'm missing what you're asking for, but I think
du -sh *
does exactly what you want. The *
is important here. With -s
, you get a summary for each directory on the command line, so with no explicit dir (implicit .
) you would just get a summary for everything, not the for each of the dirs under the top-level individually.
I tried this command. It does not include directories start with.
â Rakesh N
Apr 30 at 12:09
@RakeshN: If you want to include them you need either add extra patterns for them (.[!.]* ..?*
) or use the bash-specificshopt -s dotglob
to make*
match dotfiles.
â R..
Apr 30 at 16:11
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Maybe I'm missing what you're asking for, but I think
du -sh *
does exactly what you want. The *
is important here. With -s
, you get a summary for each directory on the command line, so with no explicit dir (implicit .
) you would just get a summary for everything, not the for each of the dirs under the top-level individually.
Maybe I'm missing what you're asking for, but I think
du -sh *
does exactly what you want. The *
is important here. With -s
, you get a summary for each directory on the command line, so with no explicit dir (implicit .
) you would just get a summary for everything, not the for each of the dirs under the top-level individually.
answered Apr 27 at 17:36
R..
1,473913
1,473913
I tried this command. It does not include directories start with.
â Rakesh N
Apr 30 at 12:09
@RakeshN: If you want to include them you need either add extra patterns for them (.[!.]* ..?*
) or use the bash-specificshopt -s dotglob
to make*
match dotfiles.
â R..
Apr 30 at 16:11
add a comment |Â
I tried this command. It does not include directories start with.
â Rakesh N
Apr 30 at 12:09
@RakeshN: If you want to include them you need either add extra patterns for them (.[!.]* ..?*
) or use the bash-specificshopt -s dotglob
to make*
match dotfiles.
â R..
Apr 30 at 16:11
I tried this command. It does not include directories start with
.
â Rakesh N
Apr 30 at 12:09
I tried this command. It does not include directories start with
.
â Rakesh N
Apr 30 at 12:09
@RakeshN: If you want to include them you need either add extra patterns for them (
.[!.]* ..?*
) or use the bash-specific shopt -s dotglob
to make *
match dotfiles.â R..
Apr 30 at 16:11
@RakeshN: If you want to include them you need either add extra patterns for them (
.[!.]* ..?*
) or use the bash-specific shopt -s dotglob
to make *
match dotfiles.â R..
Apr 30 at 16:11
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%2f440369%2fis-there-any-du-disk-usage-command-flag-that-summarizes-the-size-for-each-sub%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
2
If you don't need that information put it a file or something like that, you could try
ncdu
which shows what you need in an interactive TUI environment.â Mioriin
Apr 27 at 13:26