Subscribe to
Posts
Comments
NSLog(); Header Image

Man Date

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.

5 Responses to "Man Date"

  1. It's a capital C...

    date "+http://adium.sourceforge.net/downloads/Adium_%m-%d-%C%y.dmg"

  2. even better, use "+%m-%d-%Y"

  3. 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...

  4. +%m-%d-%Y is what you want

  5. Also a good idea to look at the right manpage, 'man strftime' ;).