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
if [ "x$1" == "x" ]; then
if [[ -z "$1" ]]; then
MONTH=$(( $(date +%-m) - 1 ))
else
MONTH=$1
shift
fi
if [ "x$1" == "x" ]; then
if [[ -z "$1" ]]; then
YEAR=$(date +%Y)
CURR=1
else
@ -19,18 +19,18 @@ else
fi
if [ $MONTH -eq 0 ];
if [[ "$MONTH" -eq 0 ]];
then
MONTH=12
fi
if [ ${CURR} -eq 1 ] && [ $(( $(date +%-m) - $MONTH )) -le 0 ]; then
YEAR=$(( $YEAR - 1))
if [[ "${CURR}" -eq 1 ]] && [[ $(( $(date +%-m) - MONTH )) -le 0 ]]; then
YEAR=$(( YEAR - 1))
fi
if [ $MONTH -lt 10 ];
if [ "$MONTH" -lt 10 ];
then
MONTH=0$MONTH
fi
tar -cvJf $YEAR-$MONTH.tar.xz $YEAR-$MONTH-*.log --remove-files
tar -cvJf $YEAR-$MONTH.tar.xz $YEAR-$MONTH-*.log --remove-files