#! /bin/bash COUNT=0 if test "$1"$ != $; #Test to see if any parameters were given then # This part executes if there is a first parameter given for a in $* do if test -f $a || test -d $a || test -L $a; then COUNT=$(($COUNT+1)); fi done; if test "$1" = "."; #This deducts 2 for the implicit . and .. then COUNT=$(($COUNT-2)); fi else # This part executes if no first parameter is given for a in .* do COUNT=$(($COUNT+1)) done; COUNT=$(($COUNT-2)) #This deducts for the implicit . and .. for a in * do COUNT=$(($COUNT+1)) done; fi echo Total $COUNT files