#! /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 echo This directory contains $COUNT files that match that description. else # This part executes if no first parameter is given for a in .* do COUNT=$(($COUNT+1)) done; for a in * do COUNT=$(($COUNT+1)) done; COUNT=$(($COUNT-2)) #This deducts for the implicit . and .. echo This directory contains a total of $COUNT files fi