Skip to content

Instantly share code, notes, and snippets.

@davejlong
Last active February 5, 2016 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davejlong/9cd8d17601faa5eb060c to your computer and use it in GitHub Desktop.
Save davejlong/9cd8d17601faa5eb060c to your computer and use it in GitHub Desktop.
I just shortened 53 lines of code to 1
DAY=$(date --date="-1 day" +%d)
MM=`date +%m`
DD=`date +%d`
DD=`expr $DD - 1`
if
[ $DD -eq 0 ]
then
case $MM in
01) DD=31
;;
02) DD=31
;;
03) DD=28
;;
04) DD=31
;;
05) DD=30
;;
06) DD=31
;;
07) DD=30
;;
08) DD=31
;;
09) DD=31
;;
10) DD=30
;;
11) DD=31
;;
12) DD=30
;;
esac
fi
case $DD in
1) DD=01
;;
2) DD=02
;;
3) DD=03
;;
4) DD=04
;;
5) DD=05
;;
6) DD=06
;;
7) DD=07
;;
8) DD=08
;;
9) DD=09
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment