github.com/unirita/cuto@v0.9.8-0.20160830082821-aa6652f877b7/_docker/cuto/shell/deljoblog.sh (about)

     1  #!/bin/sh
     2  
     3  # ################
     4  GENERAL_NUM=30
     5  # ################
     6  
     7  . ./cutoenv.sh
     8  
     9  files="$CUTOROOT/joblog/*"
    10  dirary=()
    11  for filepath in $files; do
    12    if [ -d $filepath ] ; then
    13      dirary+=("$filepath")
    14    fi  
    15  done    
    16  
    17  delnum=`expr ${#dirary[*]} - $GENERAL_NUM`
    18  if [ $delnum -lt 1 ] ; then
    19    echo Do not delete.
    20    exit 0
    21  fi
    22  
    23  count=1
    24  for dir in ${dirary[@]}; do
    25    rm -r $dir
    26    echo  deleted directory [ $dir ]
    27    count=`expr $count + 1`
    28    if [ $count -gt $delnum ] ; then
    29      break
    30    fi  
    31  done
    32  
    33  exit 0