#!/bin/bash # Summing sizes, using an inner loop TOT=0 for FILE in $@ do if [[ -x $FILE && -f $FILE ]] then 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 if [ $CNT -eq 4 ] then TOT=$(( $TOT + $DETP )) echo $FILE $DETP fi ((CNT++)) done fi done echo $TOT