USAGE="usage: rank.ksh directory"  # rank files by size

  temp_file=/tmp/filelist$$   # create a unique filename

##############################################################
# This function recursively descends a directory tree.
function expand_a_directory
{
 typeset object # object is local string variable
 cd $1          # change directory
 for object in $PWD/*
 do
    # When the object is a directory, make a recursive call.
      if [[ -d $object ]]
         then 
             expand_a_directory $object
    # when the object is a regular file, find out how big it is.
      elif [[ -f $object ]]
      then
           du -s $object >> $temp_file
       fi # ignore all objects except regular files and directories
done
}
#################################################################
# The script starts executing at next line.
# If the user doesnot enter a directory name on the command line, 
# assume $HOME.

   expand_a_directory ${1:-$HOME}
   sort -n $temp_file  # do a numeric sort

