- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Date manipulating
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 10:46 PM
10-11-2001 10:46 PM
Date manipulating
I have tried with "echo `TZ=IST+24 date`" to get previous day's date, but this doesn't work if the current time is (HH:MM) 00:00 to 05:00 AM, IST.
Can any one suggest me the better & simple command to get the previous day's date?.
Vasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 11:15 PM
10-11-2001 11:15 PM
Re: Date manipulating
This is a nice script written by Tom Danzig which he posted some time ago.
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 11:28 PM
10-11-2001 11:28 PM
Re: Date manipulating
If you have perl:
perl -e 'print scalar (localtime(time-86400)),"\n";'
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 11:29 PM
10-11-2001 11:29 PM
Re: Date manipulating
Thanks for your solution. But I am looking for single line command to get the previous day's date.
Vasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2001 12:20 AM
10-12-2001 12:20 AM
Re: Date manipulating
I don't believe there is a one line solution for what you're asking. Espeically not in shell script. However, its quite easy in perl as Robin already pointed out...but not sure if Perl is an option for you.
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2001 12:26 AM
10-12-2001 12:26 AM
Re: Date manipulating
If the perl solution is no good, we should find out why your original method is failing.
What's it show between 0:00 and 5:00? Can you output the IST timezone details in your /usr/lib/tztab. This *may* help...
Thanks, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2001 01:03 AM
10-12-2001 01:03 AM
Re: Date manipulating
echo $(TZ=IST+18:30 date)
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2001 01:09 AM
10-12-2001 01:09 AM
Re: Date manipulating
I have tried that too "echo $(TZ=IST+18:30 date)"... but it should be generic.
Thanks
Vasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2001 10:54 AM
10-12-2001 10:54 AM
Re: Date manipulating
I've had a script I've used for many years that converts calendar dates to Julian Days and back. Because I've seen so many requests for dates prior to today or 37 days from today, I've modified it with new args -p days for previous days or -n for next days. When suppiled with mm dd yyyy it converts to a Julian Day; when supplied with a Julian day it
outputs mm dd yyyy. No args and it converts today to a Julian Day.
This should work for you:
caljd.sh `caljd.sh -p 1`
The second calhd.sh takes today's date - 1 and converts it to a Julian Day which is in turn fed to the outer caljd.sh to output a mm dd yyyy.
To capture the output in a variable and get around the nested backquotes, try this:
PREV_DAY=$(caljd.sh `caljd.sh -p 1`)
If you are building file names and want to remove the spaces add the -s arg.
Regards, Clay