|
Home > Archive > Unix Programming > March 2007 > directory size
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi Friends,
How to find out a specified directory size on unix? Is there any
direct method?
| |
| shakahshakah@gmail.com 2007-03-21, 7:24 am |
| On Mar 21, 6:18 am, "Neo" <vikram.su...@gmail.com> wrote:
> Hi Friends,
> How to find out a specified directory size on unix? Is there any
> direct method?
How about something like "du -k <directory name>", e.g.:
du -k /tmp
and
du -k /tmp | sort -n
?
| |
| Jens Thoms Toerring 2007-03-21, 7:24 am |
| Neo <vikram.sutar@gmail.com> wrote:
> How to find out a specified directory size on unix? Is there any
> direct method?
Your question isn't very clear: do you mean the size if the special
file for the directory or do you want the size of the contents of
the directory? And do you want to find out via a shell command or
do you need to figure out the size from e.g. a C program?
If it's the size of the contents of a directory (the size of the
file for a directory typically is only of small interest) and
you want to get it (in kB) with a shell command simply use
du -s -k <name of directory>
From a program (and if you satisfied with kB resolution) the
simplest method probably would be to invoke the above shell
command via popen() and simply read in the result.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
| |
| SM Ryan 2007-03-21, 1:25 pm |
| "Neo" <vikram.sutar@gmail.com> wrote:
# Hi Friends,
# How to find out a specified directory size on unix? Is there any
# direct method?
Is the directory size the number of bytes in the inode, the number
of linked files, or the cumulative size of child files?
--
SM Ryan http://www.rawbw.com/~wyrmwif/
Mention something out of a Charleton Heston movie, and suddenly
everybody's a theology scholar.
| |
| David T. Ashley 2007-03-22, 1:24 am |
| "Jens Thoms Toerring" <jt@toerring.de> wrote in message
news:56cjtbF28ein1U1@mid.uni-berlin.de...
> Neo <vikram.sutar@gmail.com> wrote:
>
> If it's the size of the contents of a directory (the size of the
> file for a directory typically is only of small interest) and
> you want to get it (in kB) with a shell command simply use
>
> du -s -k <name of directory>
Or, if you want to save two keystrokes,
du -sk <name of directory>
I'm not picky ... just that I often use the "du" command and have gotten
used to typing "du -sk".
--
David T. Ashley (dta@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
|
|
|
|
|