[SLL] newest "date" in RHL coreutils messes up my script
Bill Campbell
bill at celestial.com
Fri Jun 1 11:07:20 PDT 2007
On Fri, Jun 01, 2007, Andrew Sweger wrote:
>Try,
>
>date -d '1jun07 -1 day'
A more general and portable solution that isn't dependent on the
vagaries of folks who change the API of commands would be to use
a script that uses somewhat lower level interfaces to do this.
A python script to do this might be:
#/usr/bin/env python
import time
day = 60 * 60 * 24 # too lazy to figure this out
yesterday = time.time() - day
print time.strftime('%Y-%m-%d', time.localtime(yesterday))
The one I wrote almost 20 years ago is in perl, and quite a bit
longer, which probably says more about my perl skills then than
the differences between perl and python.
BTW: I will be making a presentation this month at the Seattle
Perl Users Group on my experiences as I've moved from perl as my
primary development language to python (I'll have to dig out my
old Nomex undies for that :-).
>On Fri, 1 Jun 2007, William Kreuter wrote:
>
>> When I recently did an up2date on coreutils, "date"
>> updated to 5.2.1 from 4.5.3. This caused the result
>> of:
>>
>> date -d 0jun07
>>
>> to change from the desired "Thu May 31 00:00:00 PDT
>> 2007" to "invalid date `0jun07'".
>>
>> My script needs to obtain the previous day's date
>> on each day of the month. Since I don't see an
>> argument to date which would do the reverse of
>> "date +%s", please give me some ideas with which I
>> could keep my bash script nice and compact.
>>
>> As a stopgap, I reinstalled date 4.5.3.
>>
>> Billy
>>
>
>--
>Andrew B. Sweger -- The great thing about multitasking is that several
> things can go wrong at once.
>
--
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
``If the personal freedoms guaranteed by the Constitution inhibit the
government's ability to govern the people, we should look to limit those
guarantees.''
-President Bill Clinton, August 12, 1993
More information about the linux-list
mailing list