Below is part of a code I wrote before, I believe it will work as a unix shell script.
Main Topics
Browse All Topicswhat command/script is used to find out yesterday's date in UNIX/PERL ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
well my script looks like this,but it gives the error as I do not have GNU date :
--------------------------
#!/bin/ksh
filename="file1.d"$(date +"%Y%m%d")
./script1 $filename
echo "script1 completed"
ydate=$(date -d yesterday +"%b%d%y")
./script2 $ydate
echo "script2 completed"
#
--------------------------
here the script1 completes successfully,but I get error while script2 is executing.
error:
date: illegal option -- d
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
enter date suffix for the filename in the format mmmyy..
--------------------------
can you please tell me if the above resolution be incorporated in this ?And if so,how ? Also I would like yesterday's date to be displayed as mmmddyy where mmm is the first 3 letters of the name of the month.
Please suggest ?
The code I gave in post 24863395 is shell script code. It uses perl to generate the string. The command I gave in post 24863441 is a perl command. It would have to be enclosed in backticks to be have the output go to a variable in a shell script.
Using (time-86400) subtracts 1 normal day (24 hours of 60 minutes each with 60 seconds per each minute) from the current time. The problem with this is that for daylight savings time, a day could be 23 hours or 25 hours. Using this code within that 1 hour window on those days would give the wrong results.
Using the Date::Manip and "yesterday" does not have this problem.
Here is your code updated to get the yesterday from perl.
when I run the below script,it gives me the o/p as it is :
script :
--------------------------
#!/bin/ksh
ydate='perl -MDate::print UnixDate("Yesterday","%b%d
echo $ydate
#
--------------------------
o/p:
perl -MDate::print UnixDate("Yesterday","%b%d
--------------------------
can you figure out what can be the issue here ?
this is my current script:
--------------------------
#!/bin/ksh
ydate='perl -MDate::Manip -e 'print UnixDate("Yesterday","%b%d
echo $ydate
--------------------------
error:
syntax error at line 2 : `(' unexpected
--------------------------
Can you pls chk this and let me know what needs to be done for this ?
the other one also threw an error.Here is the script :
#!/bin/ksh
ydate='perl -MPOSIX -e 'print strftime"%b%d%y",localtime
echo $ydate
--------------------------
error:
strftime%b%d%y,localtime: not found
--------------------------
Can someone determine the issue here and let me know if there is any syntax problem somewhere ?
Also is there a way to determine if manip is there on the box or not ?
Script:
--------------------------
#!/bin/ksh
ydate=`perl -MDate::Manip -e 'print UnixDate("Yesterday","%b%d
echo $ydate
--------------------------
Error:
Can't locate Date/Manip.pm in @INC (@INC contains: /usr/perl5/5.6.1/lib/sun4-
BEGIN failed--compilation aborted.
--------------------------
However,
#!/bin/ksh
ydate=`perl -MPOSIX -e 'print strftime"%b%d%y",localtime
echo $ydate
--------------------------
This works fine.But jus wanted to confirm that would this be taking the DST into account or there is something else that I need to do ?
Business Accounts
Answer for Membership
by: mrjoltcolaPosted on 2009-07-15 at 10:54:10ID: 24862065
print strftime("%m%d%Y", localtime(time - 3600*24));