|
|
|
|
|
|
| Author |
Message |
iforone *nix forums Guru
Joined: 28 Dec 2005
Posts: 330
|
Posted: Wed Jul 19, 2006 7:52 pm Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
Robert Bonomi wrote:
| Quote: | In article <yeku05tsmgx.fsf@grymoire.com>,
Bruce Barnett <spamhater113+U060707070432@grymoire.com> wrote:
Keith Thompson <kst-u@mib.org> writes:
Yes, sorry its Linux and 'du' seems to be what im looking for.
If you have the "xdu" tool you can feed du's output to it and get a
nice interactive graphical display.
|
My little contrib (since the OP seems to *perhaps* want a GUI?, since
Windoze is mentioned).
Look into 'mc' (midnight commander) -- or even "emelFM" (which I use
some/most times, found out about it from 'dsl' linux) -- *emelFM* has
buttons for quick access to 'du', 'df', 'free', 'xterm', 'sudo', etc...
FWIW -- I'm on Debian Sid;
$ uname -a
Linux sarge 2.6.8-3-686 #1 Thu May 25 02:27:57 UTC 2006 i686 GNU/Linux
~$ apt-cache show emelfm
--------------------------------
Package: emelfm
Priority: optional
Section: utils
Installed-Size: 552
Maintainer: Debian QA Group <packages@qa.debian.org>
Architecture: i386
Version: 0.9.2-8
Depends: libc6 (>= 2.3.5-1), libglib1.2 (>= 1.2.0), libgtk1.2 (>=
1.2.10-4), libx11-6, libxext6, libxi6
Filename: pool/main/e/emelfm/emelfm_0.9.2-8_i386.deb
Size: 140684
MD5sum: 06c370b640e9de5af20ded6933baa991
SHA1: 3afa59396683ac0d8f38c27a7b57aeb99a0be467
SHA256:
74dca7d9e600f677d0a8b6205df4a73b231efc5318d6c8f789fb9062575535d6
Description: file manager for X/gtk
emelFM is a file manager that implements the popular two-window
design. It features a simple GTK+ interface, a flexible file
typing scheme, and a built-in command line for executing commands
without opening an xterm.
Tag: interface::x11, role::sw:application, role::sw:shlib,
uitoolkit::gtk, use::browsing, use::organizing, works-with::file,
x11::application
-----------------------
| Quote: | I use an old (1987) shell script called dusort (i.e. du | dusort)
It sorts the output by largest directory.
for a 'sane' number of entries in a directory,
(cd $DIR; du -s * |sort -nr)
for more pathological cases:
(cd $DIR; ls -a | xargs du -s |sort -nr)
|
Hi;
Thanks for that...
But - I'd like to know why *both* produce the same results for
me...(when I ran them while in some obscure subDir).
[caveats are as follows]
[1] I *think* the 2nd command (pathological) will yield ALL files
(hidden too... due to the 'ls -a')
[2] I understand 'cd', no prob, and am pretty sure $DIR, when run as
is; means $HOME, (with a big note that -> $DIR is just a variable),
when I used just 'cd DIR...' without the '$', it listed what was in
that _current_ DIR.
Does this need to be placed into a Shell Script and run? (#!/bin/sh
header) - or (should) can it be run from the command line Bash manually
(as I have just done)? and if so, does one need to replace the variable
$DIR with whatever DIR one wants to run the command on?
I'm _extremely_ new to any sort of scripting/programming (but have done
some light BATCH stuff in DOS), and I understand some (fair amount) of
syntax in the more used (easier) Linux commands.
Thanks
Regards |
|
| Back to top |
|
 |
Bruce Barnett *nix forums Guru
Joined: 21 Feb 2005
Posts: 324
|
Posted: Wed Jul 19, 2006 1:34 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
bonomi@host122.r-bonomi.com (Robert Bonomi) writes:
| Quote: | I use an old (1987) shell script called dusort (i.e. du | dusort)
It sorts the output by largest directory.
for a 'sane' number of entries in a directory,
(cd $DIR; du -s * |sort -nr)
|
I usually run it once a week by cron. It hep me find the sub sub sub
directory that has the biggest file.
--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract. |
|
| Back to top |
|
 |
Robert Bonomi *nix forums Guru Wannabe
Joined: 23 Mar 2005
Posts: 175
|
Posted: Mon Jul 17, 2006 1:37 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
In article <yeku05tsmgx.fsf@grymoire.com>,
Bruce Barnett <spamhater113+U060707070432@grymoire.com> wrote:
| Quote: | Keith Thompson <kst-u@mib.org> writes:
Yes, sorry its Linux and 'du' seems to be what im looking for.
If you have the "xdu" tool you can feed du's output to it and get a
nice interactive graphical display.
I use an old (1987) shell script called dusort (i.e. du | dusort)
It sorts the output by largest directory.
|
for a 'sane' number of entries in a directory,
(cd $DIR; du -s * |sort -nr)
for more pathological cases:
(cd $DIR; ls -a | xargs du -s |sort -nr) |
|
| Back to top |
|
 |
Bruce Barnett *nix forums Guru
Joined: 21 Feb 2005
Posts: 324
|
Posted: Fri Jul 07, 2006 11:06 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
Keith Thompson <kst-u@mib.org> writes:
| Quote: | Yes, sorry its Linux and 'du' seems to be what im looking for.
If you have the "xdu" tool you can feed du's output to it and get a
nice interactive graphical display.
|
I use an old (1987) shell script called dusort (i.e. du | dusort)
It sorts the output by largest directory.
#!/bin/sh
#
# sort a "du" listing by directory size
# usage: du | dusort
# see http://groups.google.com/groups?selm=4542%40ncoast.UUCP&output=gplain
FILES=
TFORM=0
while test $# -ge 1; do
case $1 in
-t) TFORM=1; ;;
*) FILES="$FILES $1"; ;;
esac
shift
done
#build complex keys so that subdirectories move with parent
awk '{ size[ $2] = $1 }
END {
for (i in size) {
printf "%s ", i;
oj = 1; l = length(i);
#build up an aggregate key from all its parents
for (j = 1; j <= l; ) {
for (; j <= l; j++) if (substr(i,j,1) == "/") break;
name = substr(i, oj, j-oj);
j++;
printf "%d ", size[name];
}
#print itself once more to compare ahead of its children
printf "%d\n", size[i];
}
}' $FILES |
#sort numerically
sort -r -n +1 -2 +2 -3 +3 -4 +4 -5 +5 -6 +6 -7 +7 -8 +8 -9|
#just print the path and its size. In two popular flavors.
awk '{if('$TFORM') printf "%s(%d)\n", $1, $NF; else
printf "%8d\t%s\n", $NF, $1}' |
#indent directories
# This awk could be combined with the previous one
# but it really performs a separate function.
# Cut it off and put it in a separate file called 'ind' if you like it.
#
# ind: indent output from du or find
#
awk '
BEGIN {blank=" "}
{
for (s=length; s > 0 && substr($0, s, 1) > " " ; s--)
;
for (e=length; substr($0, e, 1) != "/" && e > s+1; e--)
;
print substr($0, 1, s) substr(blank, 1, e-s-1) substr($0, e);
}
'
--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract. |
|
| Back to top |
|
 |
Keith Thompson *nix forums Guru
Joined: 28 Feb 2005
Posts: 5173
|
Posted: Fri Jul 07, 2006 5:59 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
junk1@davidbevan.co.uk writes:
| Quote: | What OS?
On linux I can do# du --max-depth=1
Yes, sorry its Linux and 'du' seems to be what im looking for.
|
If you have the "xdu" tool you can feed du's output to it and get a
nice interactive graphical display.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. |
|
| Back to top |
|
 |
junk1@davidbevan.co.uk *nix forums beginner
Joined: 06 Sep 2005
Posts: 4
|
Posted: Thu Jul 06, 2006 9:24 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
| Quote: | What OS?
On linux I can do# du --max-depth=1
Yes, sorry its Linux and 'du' seems to be what im looking for. |
Thanks
David Bevan
http://www.davidbevan.co.uk |
|
| Back to top |
|
 |
Steve Youngs *nix forums Guru Wannabe
Joined: 27 Feb 2005
Posts: 198
|
Posted: Thu Jul 06, 2006 9:19 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
* junk1 <junk1@davidbevan.co.uk> writes:
| Quote: | How do I see the size of a dir?
...ie NOT just the size of the dir file, but the size of a dir
including all files and sub dirs below it. - ie just like windows does.
The reason for needing this is that my server is running out of space
and im sure I just need to house keep some logs or something that are
probably building up in some far flug dir, but need an easy way of
spotting where these files are.
|
See du(1), df(1), and even find(1).
--
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
| Te audire no possum. |
| Musa sapientum fixa est in aure. |
|----------------------------------<steve@youngs.au.com>---| |
|
| Back to top |
|
 |
xemoth@gmail.com *nix forums beginner
Joined: 11 Apr 2006
Posts: 6
|
Posted: Thu Jul 06, 2006 9:05 am Post subject:
Re: How to list the size of a dir (inc all sub dirs)
|
|
|
j...@davidbevan.co.uk wrote:
| Quote: | How do I see the size of a dir?
...ie NOT just the size of the dir file, but the size of a dir
including all files and sub dirs below it. - ie just like windows does.
The reason for needing this is that my server is running out of space
and im sure I just need to house keep some logs or something that are
probably building up in some far flug dir, but need an easy way of
spotting where these files are.
|
What OS?
On linux I can do# du --max-depth=1
Owen |
|
| Back to top |
|
 |
junk1@davidbevan.co.uk *nix forums beginner
Joined: 06 Sep 2005
Posts: 4
|
Posted: Thu Jul 06, 2006 8:55 am Post subject:
How to list the size of a dir (inc all sub dirs)
|
|
|
How do I see the size of a dir?
....ie NOT just the size of the dir file, but the size of a dir
including all files and sub dirs below it. - ie just like windows does.
The reason for needing this is that my server is running out of space
and im sure I just need to house keep some logs or something that are
probably building up in some far flug dir, but need an easy way of
spotting where these files are.
Thanks
David Bevan
http://www.davidbevan.co.uk |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Nov 22, 2008 6:27 am | All times are GMT
|
|
Stag Weekends | Bad Credit Mortgages | Libros de historia | Capital One Credit Card | Mortgage
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|