#!/bin/sh # # @(#) filesize - Revision 1.1 - 01/06/97 # # ============================================================================ # Andrea Whitlock, Mobius Software Services # whitlock@mobius-soft.com # # Bug reports, questions, and suggestions should be emailed to: # mobius@mobius-soft.com # # This software is provided under the terms of the GNU copyleft # (ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0), without a warranty # of any kind. Use at your own risk. # ============================================================================= if [ ! "$1" ] then echo "usage: `basename $0` file [file [...]]" exit 1 fi len=0 for file in $@ do if [ -f $file ] then filelist="$file $filelist" templen=`echo "$file" | awk '{ print length($0) }'` if [ $templen -gt $len ] then len=$templen fi fi done ls -l $filelist | awk 'BEGIN { Kb = 1024 Mb = 1048576 } { total += $5 totalKb += ($5 / Kb) totalMb += ($5 / Mb) filler = "" for(i=1;i<=l-length($NF);i++) filler = sprintf("%s ", filler) printf("%s%s %s\n", $NF, filler, $5) if (length($5) > l2) l2 = length($5) } END { for(i=1;i<=l+3+l2;i++) dashes = sprintf("-%s", dashes) printf("%s\n", dashes) d = substr(total,1,1) if ((length(total) > 11) || ((length(total) == 11) && (d > 1))) { printf("%s bytes, %d Kbytes, %d Mbytes\n", total, total/Kb, total/Mb) } else { printf("%d bytes, %d Kbytes, %d Mbytes\n", total, total/Kb, total/Mb) } }' l=$len