pengjunling 发表于 2018-8-27 10:10:51

利用shell检查clearcase view 长期不用的目录

  #! /bin/bash
  # Get the date from the variables.
  help()
  {
  echo   "Usage: ./view_date.sh -month/-day number
  ex:./view_data.sh -month 7 :will list the view name before 7 months
  ex:./view_date -day 20 : will list the view name before 20 days"
  exit 0;
  }
  #Analysis thevariable value
  analysisVar()
  {
  case $arg in
  -month)
  date="months"
  ;;
  -day)
  date="days"
  ;;
  -h)
  help
  exit 0
  ;;
  *)
  printf "$1 \n"
  printf "Please check the input, and refer to the help \n"
  help
  exit 1
  ;;
  esac
  #check the input whether an Integer
  tmp=`echo $int |sed 's///g'`
  if[ -n "${tmp}" ]
  thenecho "Args must be integer!";
  help
  exit 1;
  fi
  }
  #Print the View Name
  printViewname()
  {
  for ((i=0;i1`"
  VIEW_DATE_RAW="`cleartool lsview -age "${ARRAY_NAME[$i]}" `"
  VIEW_DATE="`echo "$VIEW_DATE_RAW"|grep Last |awk '{print$3}'|sed 's/T.*$//g'`"
  if [[ "$VIEW_DATE" < "$INPUT_DATE" ]];then
  printf " ${ARRAY_NAME[$i]} \n "
  fi
  else
  printf "Try to list view: ${ARRAY_NAME[$i]},but meet an Error, please check this view manually!\n"
  #       $ct rmtag -view ${ARRAY_NAME[$i]}
  fi
  }
  done
  printf "$i record has been checked, OVER!! \n"
  exit 1;
  }
  #Program Start
  printf "First, checking the view status \n";
  # Get the date from the variables.
  arg=$1
  int=$2
  analysisVar;
  alias ct="/usr/atria/bin/cleartool"
  export ct="usr/atria/bin/cleartool"
  ARRAY_NAME=($(cleartool lsview -s))
  INPUT_DATE="`date --date="$2 $date ago"+%Y-%m-%d`"
  printViewname;


页: [1]
查看完整版本: 利用shell检查clearcase view 长期不用的目录