Re: Filesystem usage by Directory wise



balreddy.gattu@xxxxxxxxx wrote:
Hi All,
Iam working on sun solaris system. I am looking for a utility which
needs to display the size of each directory in the filesystem.
i.e The utility needs to display the total size of the filesystem and
the usage with each directory wise,
example:

/test filesystem
df -h will return the filesystem usage of /test.
But i want the usage like this:

/test
Total used %
2 TB 1TB 50%

Usage:
Directory name Usage %
/test/abc 0.25TB 12.5%
/test/xyz 0.5TB 25%
.................

You could start with

du -h /test

If the percentage column is not important, this may be sufficient.
Otherwise, you could try this little script:

#!/bin/sh

DIR=/test
TOTAL=`du -sk "$DIR" | sed 's/[^0-9].*//'`

( du -k "$DIR" ; du -h "$DIR" ) | sort +1 | awk '{
if ( $1 ~ /[^0-9]/ ) {
line = $0
getline
c = $1
} else {
c = $1
getline
line = $0
}
p = c * 100 / total
printf "%6.2f%%\t%s\n", p, line
}' total=$TOTAL

--
Kenan Kalajdzic
.



Relevant Pages

  • Re: [kde-linux] 20090807KL -- "Emergency" -- Lost File
    ... I was entirely unable to recover ... the display! ... If the unclean shutdown caused filesystem corruption you might have something ... Kevin Krammer, KDE developer, xdg-utils developer ...
    (KDE)
  • Re: Need WMI script
    ... is to display the status of the group and down to the user details to the ... using filesystem we can write into ... using the ">" redirection character. ...
    (microsoft.public.windows.server.scripting)
  • Re: mdctl: Device busy
    ... Errrm... ... This is a newsgroup, not a mailing list, but whatever:) ... > Is there any way to display which program or filesystem using the MD? ...
    (comp.unix.bsd.freebsd.misc)
  • Filesystem usage by Directory wise
    ... Iam working on sun solaris system. ... needs to display the size of each directory in the filesystem. ... df -h will return the filesystem usage of /test. ...
    (comp.unix.shell)
  • Re: Disk Defragmentation
    ... or overall usage of ext3 filesystem before the ... deletes and writes on a disk that is nearly full. ... that a deletion will result in a empty space. ... file in every directory for all possible usage patterns. ...
    (Ubuntu)