Advertisement
BorrowTheProgrammer

lab4.sh

Dec 15th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3.  
  4. if(($# != 3));
  5. then
  6. echo "Error! Usage: Season Weekday  YYYY-YYYY ";
  7. exit -1
  8. fi
  9.  
  10. season=$1
  11. StrDay=$2
  12. season=${season,,}
  13. StrDay=${StrDay,,}
  14.  
  15. dmy=${3: -o}
  16. set ${dmy//-/' '}
  17.  
  18. case $season in
  19. "winter") month=12;;
  20. "spring") month=3;;
  21. "summer") month=6;;
  22. "autumn") month=9;;
  23. *) echo "Error. Uncorrect name of the season"
  24. exit -1;;
  25. esac
  26.  
  27. case $StrDay in
  28. "monday") day=1;;
  29. "tuesday") day=2;;
  30. "wednesday") day=3;;
  31. "thursday") day=4;;
  32. "friday") day=5;;
  33. "saturday") day=6;;
  34. "sunday") day=7;;
  35. *) echo "Error. Uncorrect name of day of the week"
  36. exit -1;;
  37. esac
  38.  
  39. for((i=$1; i<=$2; i++));
  40. do
  41.   num=`date -d $month/01/$i +"%u"`
  42.   if((num == $day))
  43.   then
  44.     echo $i
  45.   fi
  46. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement