#!/bin/sh # # report on a list of files # countem() { if [ $totalsize ]; then : else totalsize=0 fi if [ $count ]; then : else count=0 fi size=`wc -c $1 | gawk '{print $1}'` totalsize=`expr $totalsize + $size` count=`expr $count + 1` } if [ $# -le 1 ]; then echo -n "What do you want to process " read ifiles else ifiles=$* fi echo Report generated on `uname -n` on `date` echo Report on files $ifiles for infile in $ifiles do if [ ! -r $infile ]; then echo "Error - input file $infile is not readable" continue fi countem $infile done echo "Number of files: $count" echo "Total size: $totalsize"