Advertisement
metalx1000

Holiday Dates in BASH Shell

Nov 20th, 2021
1,869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #get holidays with a BASH Shell Script and the calendar command
  2.  
  3. #holidays that don't fall on a set date
  4. #list all holidays in a range (that month or more than one month
  5. #Then grep for the holiday and cut
  6. calendar -t 250301 -A90|grep "Easter Sunday"|head -n1|cut -d\* -f1
  7. calendar -t 250601 -A30|grep Father|grep Sunday|cut -d\* -f1
  8. calendar -t 220501 -A30|grep Mother|grep Sunday|cut -d\* -f1
  9.  
  10. #format it differently
  11. date -d  "$(calendar -t 220501 -A30|grep Mother|grep Sunday|cut -d\* -f1) 2022" +%F        master
  12. 2022-05-08
  13.  
  14. #If you don't have calendar on your system
  15. #you can use ncal for some holidays
  16. #example Father's day is the 3rd Sunday in June
  17. ncal -m june 2025|grep "^Su"|awk '{print $4}'
  18. #somthing like Easter might be a little more difficult
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement