With date -d
could display the future or next date
$ date -d "next mon"
Mon May 13 00:00:00 CST 2019
$ date -d "mon"
Mon May 13 00:00:00 CST 2019
Unfortunately, it failed to display the previous weekday
$ date -d "previous Monday"
date: invalid date ‘previous Monday’
How could display the previous weekday in a string-format?
Use
last
instead ofprevious
:This is documented in
info date
, and the specific mention oflast
is in the "29.6 Day of week items" section (thanks to @Jos and @hobbs for finding it):