- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Get the month 2 months ago
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
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
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
12-29-2017 01:15 AM
12-29-2017 01:15 AM
I have found following:
prevmonth=`perl -MPOSIX=strftime -le '@t = localtime; $t[3] = 1; $t[4]--;print strftime("%b", @t)'`
This will return the previous month.
I want the month 2 months ago. For instance now it is December. Above will return me "Nov". I want it to return "Oct". What changes do I have to make on the above? I can't figure it out.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2017 07:13 AM
12-29-2017 07:13 AM
SolutionI had luck by manipulating the $t[4] section:
perl -MPOSIX=strftime -le '@t = localtime; $t[3] = 1; $t[4] -= 2;print strftime("%b", @t)'
Oct
perl -MPOSIX=strftime -le '@t = localtime; $t[3] = 1; $t[4] -= 3;print strftime("%b", @t)'
Sep
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2017 02:19 PM
12-29-2017 02:19 PM
Re: Get the month 2 months ago
Thank you very much.