#!/usr/bin/ksh # Function : Add up the disk space in a directory if [ $# -ne 1 ];then echo "Usage: `basename $0` " elif [ ! -d $1 ];then echo "$1 is not a directory" else TOTAL=0 FILE_COUNT=0 ls -l $1 | grep -v ^d | sed '1d' | tr -s ' '| cut -s -f5 -d' ' | while read SIZE do TOTAL=$(($SIZE+$TOTAL)) FILE_COUNT=$(($FILE_COUNT+1)) done echo "$FILE_COUNT files are using ${TOTAL}" fi