: # loop for all files in the current directory # check if the first clarg is -v case $1 in -v) shift verbose=1 ;; *) verbose=0 ;; esac if [ $verbose -eq 1 ] then echo $0 Verbose mode is on fi # if no command line argument is given, set it to current directory if [ $verbose = 1 ] then echo Test $0: $# $@ fi if [ $# = 0 ] then set . fi if [ $verbose = 1 ] then echo Test $0: $# $@ fi # 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