#! /bin/sh
#
# @(#)disk_usage 1.1 86/09/25 SMI
#
# report on disk usage in /proto for different exclude lists
#

TMPFILE=/tmp/disk.usage.$$
ROOTSUM=0
USRSUM=0

for LIST in $*; do

	if expr match "${LIST}" "usr." > /dev/null; then
		DIR=/proto/usr
	else
		DIR=/proto
	fi

	SUM=0
	while read FILE; do
		SIZE=`(cd ${DIR};  du -s $FILE) | sed 's/	.*//'` 
		SUM=`expr ${SUM} + ${SIZE}`
		echo "${LIST}:	${SUM} Kbytes"
	done < ${LIST} > ${TMPFILE}

	tail -1 ${TMPFILE}

	SUMLINE=`tail -1 ${TMPFILE}`
	if [ "${DIR}" = "/proto/usr" ]; then
                SUM=`expr match "${SUMLINE}" ".*:	\([0-9]*\) Kbytes"`
                USRSUM=`expr ${USRSUM} + ${SUM}`
	else
                SUM=`expr match "${SUMLINE}" ".*:	\([0-9]*\) Kbytes"`
                ROOTSUM=`expr ${ROOTSUM} + ${SUM}`
	fi

done

echo
echo "root total:	${ROOTSUM} Kbytes"
echo
echo "usr total:	${USRSUM} Kbytes"
echo

rm -fr ${TMPFILE}
