- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell script to generate yesterday date
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
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
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-13-2009 10:16 PM
тАО10-13-2009 10:16 PM
Shell script to generate yesterday date
i need to generate the date of yesterday with the following format:
like 14-Oct-09
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 10:34 PM
тАО10-13-2009 10:34 PM
Re: Shell script to generate yesterday date
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=541033
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=563529
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=21953
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1227549
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=144178
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=9251
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=113540
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1108220
Use Clay's caljd.sh or caljd.pl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 10:38 PM
тАО10-13-2009 10:38 PM
Re: Shell script to generate yesterday date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 10:40 PM
тАО10-13-2009 10:40 PM
Re: Shell script to generate yesterday date
yesterday=`TZ=aaa24 date +"%d-%b-%y"`
echo $yesterday;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 11:18 PM
тАО10-13-2009 11:18 PM
Re: Shell script to generate yesterday date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 11:23 PM
тАО10-13-2009 11:23 PM
Re: Shell script to generate yesterday date
http://www.hpux.ws/merijn/caldj-2.3.sh
There is an older one here:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=21953&admit=109447627+1255504783045+28353475
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 11:54 PM
тАО10-13-2009 11:54 PM
Re: Shell script to generate yesterday date
Here is the command
$ dt=`TZ=$TZ-24 date '+%d-%b-%y'`;echo $dt
15-Oct-09
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 11:58 PM
тАО10-13-2009 11:58 PM
Re: Shell script to generate yesterday date
Sorry my previous post is for tomorrows here is the yesterday one
$ date
Wed Oct 14 03:57:40 EDT 2009
$ dt=`TZ=$TZ+24 date '+%d-%b-%y'`;echo $dt
13-Oct-09
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2009 12:37 AM
тАО10-14-2009 12:37 AM
Re: Shell script to generate yesterday date
#include
main()
{
long t;
char buf[256];
t=time(0)-24*3600;
strftime(buf,255,"%d-%b-%y", localtime(&t));
printf("%s\n",buf);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2009 03:53 AM
тАО10-14-2009 03:53 AM
Re: Shell script to generate yesterday date
Using the 'TZ" variable and adding or subtracting hours from it only works for UTC time.
One totally accurate, safe way to do what you want is to use Perl. For your specification:
# perl -MPOSIX -le 'print strftime "%d-%b-%y",localtime(time-(60*60*24))'
13-Oct-09
You can use the same formatting directives to the strftime() function that you would use with the 'date' command.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2009 12:53 AM
тАО10-21-2009 12:53 AM