: # loop for all files in the current directory # if no command line argument is given, set it to current directory echo Test $0: $# $@ if [ $# = 0 ] then set . fi echo Test $0: $# $@ # loop for each command line argument for clarg do echo Test $0 $clarg # check to see if clarg is a readable, executable directory if [ -d $clarg -a -r $clarg -a -x $clarg ] then # save current directory and cd to directory in clarg echo Test $0 `pwd` origDir=`pwd` echo Test $0 $origDir cd $clarg # loop for each item in the directory for loopvar in `ls` do echo Test $0: loopvar is $loopvar # test if the item is a file if [ -f $loopvar ] then echo $loopvar is a file "\c" # test if the file is readable if [ -r $loopvar ] then echo and is readable else echo and is NOT readable fi fi done # reset directory to original Directory cd $origDir elif [ -d $clarg ] then echo $0: Directory \"$clarg\" is not readable and executable 1>&2 else echo $0: Argument \"$clarg\" is not a directory 1>&2 fi done