Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get yesterday's date on the terminal, mac os x



A bit convoluted:

    date -r  $((`date '+%s'` - 86400))

but seems to work. ;-)

Not off topic ;-) I need to get last month from the date

MON=`date +"%m"`
((MON=$MON-1))
-bash: ((: MON=09: value too great for base (error token is "09")

So, do this

MON=`date +"10#%m"`
((MON=$MON-1))
echo $MON
8

How entertaining - bash treats the leading zero as an indicator of octal.

Same would need to be done for any of the `date` formats that return leading zero as part of the result.

8)
----------------------------------
Chris Janton  - face at CentosPrime dot COM
Netminder for Opus1.COM


_______________________________________________ Do not post admin requests to the list. They will be ignored. Macos-x-server mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/macos-x-server/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.