Solved

display previous one day's date using SUN Solaris 7

Posted on 2002-03-06
7
1,824 Views
Last Modified: 2013-12-05
Hi!
I have some UNIX script need to help from you all experts.
How do display previous one day's using UNIX script on SUN Solaris?
The date of type display is YYMMDD

E.g: (1) "For display today date"
#date
Thu Mar  7 13:36:12 SGT 2002
 
E.g: (2) "For display today date with type YYMMDD"
#date -u '+%y%m%d'
020307

How to display the date on one day before current day?
I meant if today is 020307 (2002 March 07), when I type the command it should be display: 020306 (2002 March 6).

Thank you very much!
Geoffry.
0
Comment
Question by:geoffry
7 Comments
 
LVL 24

Expert Comment

by:SunBow
ID: 6847740
Change the clock.
If your application needs that so badly from OS, for example, to simulate being in another country, another time zone, etc., then best to just configure the server as if it was located in the area being serviced. That gets around a few other problems, such as TZ & DST.

If not, just a cosmetic for application, then the tools of the application should modify it, and not require any hacks to the OS clock.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6847743
(not to mention synchronization and networking communication)
0
 
LVL 4

Expert Comment

by:newmang
ID: 6848573
Can you explain the situation where you need this function as the way to do it would depend on why you want to do it.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 300 total points
ID: 6852675
env TZ=GMT+24 date +%y%m%d
# assuming that your TZ is GMT
0
 
LVL 1

Expert Comment

by:mbreuer
ID: 6861677
Don't know if the standard sun date routine has this... linux does:

date --date=yesterday works for me.  You could use the gpl'd date routine and compile on solaris if not already supported.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6862656
--date is a GNU option;
My TZ suggestion works on any flaviour of UNIX/Linux for at least 24 hours timeshift (up to .. I don't realy know, depends on UNIX ;-)
0
 
LVL 2

Author Comment

by:geoffry
ID: 6887526
Thank you very much!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now