Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have read Mike Lacey's FAQ on cal

Status
Not open for further replies.

unixkid

IS-IT--Management
May 22, 2001
105
US
I have read Mike Lacey's FAQ on calulating yesterdays date. I do need to set yesterdays date as a VAR in a script. Can anyone tell me what I might be doing wrong?

yday= 'cat /opt/mlacey.script'

echo $yday
yday -->nothing comes back<--
 
First , I believe you want to get the output of /opt/mlacey.script in your variable and not the content of the script.
syntax should be :

yday=`/opt/mlacey.script`

If you have a Sun keyboard, make sure you use the ` located to the left of the &quot;1&quot; key.
(use ` not ').
 
Yes it looks like this will work better but now It appears my problem is Mike's script produces yesterdays date as 10/05/2001 --> I need the year to be two digets. Any advice?
 
You can either modify the mlacey.script or modify your own. To modify the Perl do the following:

$yr = substr($yr, 2, 2);

To modify your script:
yday = `echo $yday | cut -c 1-6,9-10`
 
Also check out thread80-105565 for a method suggested by cfsalmeida
CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top