Man Date
Posted November 14th, 2003 @ 08:53am by Erik J. Barzeski
There's something unusual about typing man date
into your terminal. Depending on where your mind is at the moment, there are a few interesting ways you can take such a short phrase. But, hey, I digress.
I'm trying to download Adium automatically every day at noon. The format they use is illustrated by today's file: http://adium.sourceforge.net/downloads/Adium_11-14-2003.dmg
. Given that, I created this command:
date "+http://adium.sourceforge.net/downloads/Adium_%m-%d-%c%y.dmg"
Unfortunately, that produces:
http://adium.sourceforge.net/downloads/Adium_11-14-Fri Nov 14 08:48:53 200303.dmg
Removing the %c produces:
http://adium.sourceforge.net/downloads/Adium_11-14-03.dmg
Close, but I kind of need that "20". Guess I'll just add it back in. The man page says that yy is the year, and that cc is the century. Perhaps the two are out of sync. That, or I'm losing it. Anyway, it works now.
Posted 14 Nov 2003 at 9:11am #
It's a capital C...
date "+http://adium.sourceforge.net/downloads/Adium_%m-%d-%C%y.dmg"
Posted 14 Nov 2003 at 10:10am #
even better, use "+%m-%d-%Y"
Posted 14 Nov 2003 at 10:15am #
actually, while i'm here, i may as well mention that mm-dd-yyyy is a really dumb way to format dates. better to use yyyy-mm-dd, so things will sort all nice and pretty-like. i know there's an ISO for that, too...
Posted 14 Nov 2003 at 10:27am #
+%m-%d-%Y is what you want
Posted 14 Nov 2003 at 2:12pm #
Also a good idea to look at the right manpage, 'man strftime' ;).