#! /bin/bash # A useful shell script to calculate the number of bytes # used by all files in the given directory that end with a particular extension FILES=`ls *.${1}` # get the list of files TOT=0 for FILE in $FILES do DET=`ls -l $FILE` # for a particlar file, get its details CNT=0 for DETP in $DET # cycle through file details until get to size do #echo "$CNT $DETP" if [ $CNT -eq 4 ] then TOT=$(( $TOT + $DETP )) #echo $DETP fi ((CNT++)) done done echo $TOT