Easy date calculations in Unix scripts with GNU date
When I was writing a post about using date command to confirm date and time in your Unix scripts, I made a note in my future posts list to cover the date calculations - finding out the date of yesterday or tomorrow, and so on. Today I’ll show you the simplest way to calculate this.
GNU date command advantage
GNU version of the date command, although supporting a common syntax, has one great option: it allows you to specify the desired date with a simple string before reporting it back. What this means is that by default this specified date is assumed to be “now”, but you can use other keywords to shift the result of the date command and thus show what date it was yesterday or a week ago:
Leave a Reply