Fixed lots of issues when trying to pack previous months

This commit is contained in:
Trey Blancher 2023-10-02 16:44:26 -04:00
parent 1fcc3668c5
commit 787c4c5b2f
1 changed files with 7 additions and 7 deletions

View File

@ -2,14 +2,14 @@
PATH=/Users/tblancher/homebrew/opt/coreutils/libexec/gnubin:/Users/tblancher/homebrew/opt/gnu-tar/libexec/gnubin:/Users/tblancher/bin:/Users/tblancher/homebrew/bin:/Users/tblancher/homebrew/sbin:/Users/tblancher/gem/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/sbin:/usr/sbin:/Users/tblancher/bin PATH=/Users/tblancher/homebrew/opt/coreutils/libexec/gnubin:/Users/tblancher/homebrew/opt/gnu-tar/libexec/gnubin:/Users/tblancher/bin:/Users/tblancher/homebrew/bin:/Users/tblancher/homebrew/sbin:/Users/tblancher/gem/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/sbin:/usr/sbin:/Users/tblancher/bin
if [ "x$1" == "x" ]; then if [[ -z "$1" ]]; then
MONTH=$(( $(date +%-m) - 1 )) MONTH=$(( $(date +%-m) - 1 ))
else else
MONTH=$1 MONTH=$1
shift shift
fi fi
if [ "x$1" == "x" ]; then if [[ -z "$1" ]]; then
YEAR=$(date +%Y) YEAR=$(date +%Y)
CURR=1 CURR=1
else else
@ -19,18 +19,18 @@ else
fi fi
if [ $MONTH -eq 0 ]; if [[ "$MONTH" -eq 0 ]];
then then
MONTH=12 MONTH=12
fi fi
if [ ${CURR} -eq 1 ] && [ $(( $(date +%-m) - $MONTH )) -le 0 ]; then if [[ "${CURR}" -eq 1 ]] && [[ $(( $(date +%-m) - MONTH )) -le 0 ]]; then
YEAR=$(( $YEAR - 1)) YEAR=$(( YEAR - 1))
fi fi
if [ $MONTH -lt 10 ]; if [ "$MONTH" -lt 10 ];
then then
MONTH=0$MONTH MONTH=0$MONTH
fi fi
tar -cvJf $YEAR-$MONTH.tar.xz $YEAR-$MONTH-*.log --remove-files tar -cvJf $YEAR-$MONTH.tar.xz $YEAR-$MONTH-*.log --remove-files