The general problem is that the perl script detects the Friday, then subtracts 5 days to snd up on Sunday, rather than subtracting 4 days to get to the Monday. awk is great, but sed'll do it too ... I mean, leverage cal to do the date arithmetic :-) The actual logic is far uglier, but if you have a free couple of days, you'll be satisfied that sed is indeed Turing complete. echo " M T W T F" for i in $(seq 2015 2115) do echo $i Jan $(cal 1 $i |sed -nr 's/^[[:digit:]]+ (([[:digit:]]+ ){5}).*/\1/;t h;b e;:h h;:e $x;$p') done M T W T F 2015 Jan 26 27 28 29 30 2016 Jan 25 26 27 28 29 2017 Jan 23 24 25 26 27 2018 Jan 22 23 24 25 26 2019 Jan 21 22 23 24 25 2020 Jan 27 28 29 30 31 2021 Jan 25 26 27 28 29 2022 Jan 24 25 26 27 28 2023 Jan 23 24 25 26 27 2024 Jan 22 23 24 25 26 2025 Jan 27 28 29 30 31 2026 Jan 26 27 28 29 30 ... 2106 Jan 25 26 27 28 29 2107 Jan 24 25 26 27 28 2108 Jan 23 24 25 26 27 2109 Jan 21 22 23 24 25 2110 Jan 27 28 29 30 31 2111 Jan 26 27 28 29 30 2112 Jan 25 26 27 28 29 2113 Jan 23 24 25 26 27 2114 Jan 22 23 24 25 26 2115 Jan 21 22 23 24 25 -jim