SUMMARY: How to get disk usage

From: Dion Rivera <dion_rivera_at_hotmail.com>
Date: Mon, 28 Sep 1998 17:10:57 -0700 (PDT)

The following scripts was sent in by Simon Millard and works really well
on getting stats you can use on a directory.
Enjoy! and thanks Simon.

Dion

## tool to display the number of directories, files and blocks from
# a parent directory#
PID=`ps | head -2 | tail -1 | awk '{print $1}'`
OUTFILE=/tmp/filesysanal.$PID
ls -a | tail +3 > $OUTFILE
echo "Analysis of `pwd` - This may take some time"echo " "
echo "Filename\t\t\tType\t Files\t1024K blocks"
echo "========\t\t\t====\t =====\t====="
for i in `cat $OUTFILE`
do
        TYPE=`file $i | awk '{print $2}'`
        case "$TYPE" in
                "directory") FILETYPE="DIR";;
        esac
        FILES=`find $i -print -type f | wc -l`
        BLOCKS=`du -sk $i | awk '{print $1}'`
        NAME=`echo $i | awk '{printf ( "%-25.25s", $1)}'`
        echo "$NAME\t$FILETYPE\t$FILES\t$BLOCKS"

done
rm $OUTFILE

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
Received on Tue Sep 29 1998 - 00:11:58 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT