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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date - n 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

On a Solaris 8 systen from a Bourne shell script I need to set a variable value to the current date - 3.

I have been playing with the date command but I think I am making this too hard. I am not sure how to extract the date 3 days ago using it.

The format I need it in is: date '+%Y%m%d'
Example: 20060630

What is a simple way to get the value of date-3 in this format?

Thanks,

Michael42
 

Try:
Code:
date_3=`TZ=PST+72 date +%Y%m%d`
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
LKBrwnDBA,

This is great stuff. Thanks for posting!

This TZ mechinism, I cannot find it in man or other common sources. Can anyone recommend a source that describes there usage in more detail?

Thanks,

Michael42
 
TZ is timezone

echo $TZ

mine is GMT0BST

try man -k tz

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
Perhaps man environ ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
or man env

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top