Thanks for this Vincent. You wrote:
> You can get size of your directory by going in the parent directory
> of the one you want to estimate the size and typing following
> statement :
>
> du -m --max-depth=0 <name of directory>
This gives the disk usage, rather than the total of the file sizes.
Adding the b option gives the results in bytes, rather than 1024 byte
blocks, so doing this:
du -mb --max-depth=0 <name of directory>
from the parent directory, or from the directory itself:
du -mb --max-depth=0 .
gives results in bytes - but it is for blocks allocated. So an empty
directory on my system appears as 4096 bytes. This is a useful
statistic, but not the main one I want.
I don't know of a way in Linux / Unix to traverse subdirectories to
count all the file sizes, without writing a script to do so. Then, one
might want to be careful about following symlinks to files outside that
directory structure, and to directories.
On reflection, I realised that what I really wanted to know was how much
each Maidir (mailbox from my point of view as a user) was taking up in
the resulting tar.gz backup file.
The following incantation traverses the files in a directory and
produces the number of bytes in the files and directories - or something
pretty close to it, based on how these files and directories are packed
into tar format:
tar --totals -c <directory> > /dev/null
but when directed at an empty directory, this still produces 10240
bytes. So this is not much good.
cp doesn't help us - it does not count bytes.
Here's another approach:
gzip -crv <directory> > /dev/null
but this produces no input or output byte count on its own.
Ideally I would like to know for each Maildirs:
1 - The number of messages (though I can already find this via the
client).
2 - The space taken on disc - with the du command.
3 - The total size of the messages.
4 - Its size after being tarred and gzipped.
The last one is what I am really concerned with. It can be done with:
tar --totals -cz <directory> | wc -c
This causes tar to pass its output through gzip and then to "wc" word
count, with the -c option to show only the number of bytes, not lines
and words.
Or with the du command and more simply, without tar's "Bytes written"
figure, which only approximates the total size of the files:
du -mb --max-depth=0 <directory>
tar --totals -cz <directory> | wc -c
Now, I want to invent a Perl script to do this for all my Maildirs in
alphabetical order, and create a nice little body of text of their name,
their disk usage in 1024 byte blocks, and their tar-gzipped size, with
commas for thousands and millions to make it easier for me to read.
Then, to make it easier to use when my mind is in email mode, rather
than Linux command line mode, I could set up a Maildrop filter rule to
look out for an email from myself with a special subject line. That
rule would run the Perl script and the resulting email would contain the
report on mailbox sizes.
- Robin
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users