====== 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