Unix date magic
The Unix date
command has a cool feature I didn’t know about (hat tip to Dave C. for his comment about it on Dr. Drang’s blog). Turns out you can add multiple -v
options to adjust dates — for example, to get the date of last Friday:
$ date -v -fri
Fri Sep 21 ... 2012
Or next Thursday:
$ date -v +thu
Thu Sep 27 ... 2012
Or the next Tuesday after two weeks from today:
$ date -v +2w -v +tue
Tue Oct 2 ... 2012
Or thirty seconds from now:
$ date -v +30S
Or five hours ago:
$ date -v -5H
Or ten years, a month, and three days from now (and no, I have no idea why you’d use something like that):
$ date -v +10y -v +1m -v +3d
Thu Oct 27 ... 2022
And so on.