date -d "2 weeks ago" +%b
which is equivalent in Solaris?, I searched online, but nothing.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
date can't do that. AFAICT from the man page, it can't even display an arbitrary date, so you can't just get the date in seconds since the epoch, subtract 2 weeks (14 * 86400 = 1209600 seconds), and then give that to
If you can, install GNU date. Either under /usr/local/gnu/bin or similar if you have root (BTW, GNU Coreutils which contains GNU date is available pre-packaged for Solaris here), or in ~/bin if not.
If you can't install GNU date, your next best option would be to write a wrapper around
strftime() to do the calculation mentioned above, or write a 5-liner in perl or python both of which have excellent date handling libs.
gdate instead of
date. This will give you GNU date as opposed to the traditional Solaris date command. This will work unless you are on a very old version of Solaris, i.e. Solaris 10 or before.
Note that if you are in a local zone then your sysadm may have decided for you that
gdate shouldn't be available, despite the fact that it is available by default in the global zone. In that case go tell him he's a ..... (use your own word here).
For more information: