- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help to do a script
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
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
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
тАО03-10-2009 03:37 PM
тАО03-10-2009 03:37 PM
Help to do a script
I'm trying to make a script by using shell. I would like to substract 1 hour to the current date and to get the result in this format (Month Day Hour):
Mar 10 18 (It is March 10 at 19 hours)
Mar 9 23 (It is March 10 at 00 hours)
My variable is:
i=`date +'%-3.4h %2.1d %H'`
How can i substract 1 hour to my variable $i in shell?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 03:44 PM
тАО03-10-2009 03:44 PM
Re: Help to do a script
h = $((i -1))
See the example here - http://www.unix.com/shell-programming-scripting/11953-korn-shell-script-getting-yesterdays-date.html
regards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 03:51 PM
тАО03-10-2009 03:51 PM
Re: Help to do a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 03:57 PM
тАО03-10-2009 03:57 PM
Re: Help to do a script
Use Perl;
# i=$(perl -MPOSIX -le 'print strftime "%h %2d %H",localtime(time-3600)')
# echo ${i}
Mar 10 18
Use the same date formatting directives that you are accustomed to using --- see the 'date' manpages if you like.
This above code handles one-hour (3600 second) transitions across months and years without any other effort.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 04:05 PM - edited тАО10-01-2011 07:53 PM
тАО03-10-2009 04:05 PM - edited тАО10-01-2011 07:53 PM
Re: Help to do a script
See Clay's caljd.sh script:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441
- Tags:
- caljd