Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- if(($# != 3));
- then
- echo "Error! Usage: Season Weekday YYYY-YYYY ";
- exit -1
- fi
- season=$1
- StrDay=$2
- season=${season,,}
- StrDay=${StrDay,,}
- dmy=${3: -o}
- set ${dmy//-/' '}
- case $season in
- "winter") month=12;;
- "spring") month=3;;
- "summer") month=6;;
- "autumn") month=9;;
- *) echo "Error. Uncorrect name of the season"
- exit -1;;
- esac
- case $StrDay in
- "monday") day=1;;
- "tuesday") day=2;;
- "wednesday") day=3;;
- "thursday") day=4;;
- "friday") day=5;;
- "saturday") day=6;;
- "sunday") day=7;;
- *) echo "Error. Uncorrect name of day of the week"
- exit -1;;
- esac
- for((i=$1; i<=$2; i++));
- do
- num=`date -d $month/01/$i +"%u"`
- if((num == $day))
- then
- echo $i
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement