home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / unix_c / utils / bytes.sh < prev    next >
Encoding:
Text File  |  1989-03-21  |  475 b   |  26 lines

  1.  
  2. # bytes is a program to add the number of bytes shown in an ls -la for the
  3. # directory passed to it as a parameter, or the current directory as default.
  4.  
  5. total=0
  6. NULL=""
  7. ADD=${1-`pwd`}
  8. if (test $ADD != `pwd`)
  9.    then
  10. cd $ADD
  11.    fi
  12. ls -l | while LINE=`line`
  13.   do
  14. num=`echo "$LINE" | sed 's/  */ /g' | cut -f5 -d" "`
  15. if [ {$num} = {$NULL} ]
  16.    then
  17. continue
  18.    else
  19. total=`expr $total + $num`
  20. echo "Total for ${ADD} directory is:   $total" >tot
  21.    fi
  22.   done
  23.  
  24. cat tot; rm tot
  25.  
  26.