12-15-2006 12:50 AM
I have a shell script which needs to get today's date (i.e. 20061215) and add 1 day to this date, so I'd end up having 20061216 in a variable...
In Linux's gnu date command, I have `date -d "+1 day" +"%Y%m%d"` which works perfectly. Installing GNU Date on HPUX isn't an option for me... and I've already got my hole script in shell... so Perl isn't a friendly approach...
Has anyone done this?
12-15-2006 12:54 AM
which gives me the epoch time.. so I'd end up with something like "1166123240". I could just add up "86400", which totals a day's worth, but then, how do I convert that to a date string?
thx again! Pat
12-15-2006 12:55 AM
Well, if you don't want Perl, I'd use Clay Stephenson's 'caljd' date manipulation utility!
You can download it from Merijn's website:
12-15-2006 01:30 AM
I have to add that Perl *is* such a straightforward approach for your task, though:
# perl -MPOSIX=strftime -le 'print strftime("%Y%m%d",localtime(time+(86400)))'
Plus, as you can see, the syntax mimics the GNU 'date' since both use the 'strftime' C library notation.
12-15-2006 01:44 AM
perl -MPOSIX -le 'print for strftime( "%Y%m%d", localtime(time + 86400) )'
which does the same.