I had a need to get the last Friday of each month of 2025.
- This can be changed to get any other last day by changing the wday variable.
- su, mo, tu, we, th, fr, sa
let wday = 'fr'
let year = 2025
cal -m -t --week-start $wday --full-year $year |
group-by month |
items {|mon cal|
{Friday: ($'($year)-($mon)-($cal | last | get $wday)' |
format date "%F" )
}
}╭────┬────────────╮
│ # │ Friday │
├────┼────────────┤
│ 0 │ 2025-01-31 │
│ 1 │ 2025-02-28 │
│ 2 │ 2025-03-28 │
│ 3 │ 2025-04-25 │
│ 4 │ 2025-05-30 │
│ 5 │ 2025-06-27 │
│ 6 │ 2025-07-25 │
│ 7 │ 2025-08-29 │
│ 8 │ 2025-09-26 │
│ 9 │ 2025-10-31 │
│ 10 │ 2025-11-28 │
│ 11 │ 2025-12-26 │
├────┼────────────┤
│ # │ Friday │
╰────┴────────────╯