testdir

 

#!/bin/bash
#----------------------------------
####testdir.sh
####Author:

####Time:16/12/2008
####Specification: this file's function is deleting the empty file and dir
#-----------------------------------

cd "D:\practice\Unix\testdir"

for filename in `ls`
do
  if test -d  $filename
  then
   test -s  $filename || rmdir $filename
   echo "the empty dir $filename was deleted !"; echo " `date`: ; `whoami`: ; $filename; type: dir " >>log.txt
  elif test -f $filename
   then
   test -s $filename || ( rm $filename && echo "the empty file $filename was deleted !" && echo " `date`: ; `whoami`: ; $filename; type: file " >>log.txt)
  fi
done
exit 1

你可能感兴趣的:(Date,function,unix,File)