Matthew Graybosch
author by choice, techie by necessity

atomdate: a trivial shell script

I'm so lazy that I wrote a shell script for a date command with a particular format.

Most Unix-like operating systems include a handy little utility called date(1) that does what you might expect. It prints to standard output the current date and time according to the system clock.

By default, this is the sort of output you get when you use the date command:

using "date" in a shell prompt
kether$ date
Fri Nov 27 13:58:19 EST 2020

On a modern Unix-like system, there are easier ways to get the date and time than bothering to type the date command into a shell prompt. However, the command can still be handy while writing shell scripts, though its default output can leave somewhat to be desired.

For example, date's default output won't do if you're trying to generate an Atom feed. Fortunately, the date command's output can be formatted using a system library called strftime(3).

Being the lazy person I am, I can't be bothered to open the manual page for strftime every time I want a date to use in an Atom feed, so I created a little shell script called "atomdate".

the "atomdate" script without license info

date "+%Y-%m-%dT%H:%M:%S.000-05:00"

That's right. I wrote a shell script for that. I use it all the time, though, so I think it was worth it.