With some pretty important holidays right around the corner, you might need to be reminded how much longer you have to prepare.
Fortunately, you can get a lot of help from the date command. In this post, we’ll look at ways that date and bash scripts can tell you how many days there are between today and some event that you’re anticipating.
First a couple hints at how this is going to work. The date command’s %j option is going to show you today’s date as a number between 1 and 366. January 1st, as you’d expect, will be displayed as 1 and December 31st will be 365 or 366 depending on whether it’s leap year. Go ahead and try it. You should see something like this:
Thanks to Sandra Henry-Stocker (see source)