Last active
February 5, 2016 17:30
-
-
Save davejlong/9cd8d17601faa5eb060c to your computer and use it in GitHub Desktop.
I just shortened 53 lines of code to 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DAY=$(date --date="-1 day" +%d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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