linux:date_time:get_last_sunday_of_month
Table of Contents
Linux - Date Time - Get last Sunday of month
Using bash
cal -m | awk ‘{print $7}’ | grep -E ‘[0-9]’ | tail -n 1
returns:
28
NOTE: The cal command is run using the -m switch to have the first day of week to be Monday.
Only using awk
cal -m | awk ‘$7!=””{l=$7} END {print l}’
returns:
28
linux/date_time/get_last_sunday_of_month.txt · Last modified: 2023/07/17 14:12 by peter