User Tools

Site Tools


linux:date_time:get_last_sunday_of_month

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

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki