remove-empty-cvslogs.sh 557 B

123456789101112131415161718192021
  1. #!/bin/sh
  2. # Find all logs that show no changes and remove them
  3. for LOGFILE in ${HOME}/cvslogs/* ; do
  4. if [ ! -d "${LOGFILE}" ]; then
  5. NUMLINES=`grep -v '^[\?M].*' "${LOGFILE}" | wc -l`
  6. if [ ${NUMLINES} == 0 ] ; then
  7. rm "${LOGFILE}"
  8. fi
  9. fi
  10. done
  11. # Store the last years cvslogs in a subfolder on new year
  12. if [ X`date +%d%m` = X'0101' ]; then
  13. YEAR=`date +%Y`
  14. YEAR=$((YEAR - 1))
  15. echo "Storing the logs from ${YEAR} to \"${HOME}/cvslogs/${YEAR}/\""
  16. mkdir -p "${HOME}/cvslogs/${YEAR}"
  17. mv ${HOME}/cvslogs/cvs*${YEAR}* "${HOME}/cvslogs/${YEAR}/"
  18. fi