- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Date - how to get (year -1)
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
тАО04-28-2010 10:20 PM
тАО04-28-2010 10:20 PM
Date - how to get (year -1)
how to get year-1?
YRLESS=`date +%Y-1`
echo $YRLESS
The above does not work.
Regards
Feng Lin
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 10:32 PM
тАО04-28-2010 10:32 PM
Re: Date - how to get (year -1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 10:34 PM
тАО04-28-2010 10:34 PM
Re: Date - how to get (year -1)
$ YRLESS=$(( $(date +%Y) - 1 ))
Or:
$ (( YRLESS = $(date +%Y) - 1 ))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 10:39 PM
тАО04-28-2010 10:39 PM
Re: Date - how to get (year -1)
You can do this way, cy=current year, py=previous year
$ cy=date +%Y
$ py=`expr $cy - 1 `
$ echo $py
2009
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 10:47 PM
тАО04-28-2010 10:47 PM
Re: Date - how to get (year -1)
2009
Enjoy, Have FUN! H.Merijn [ could not resist to do it even shorter ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2010 04:53 PM
тАО04-29-2010 04:53 PM
Re: Date - how to get (year -1)
echo $YRLESS
/Tor-Arne
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2010 04:56 PM
тАО04-29-2010 04:56 PM
Re: Date - how to get (year -1)
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2010 06:22 PM
тАО04-29-2010 06:22 PM
Re: Date - how to get (year -1)
If you are happy with the answers you have gotten, please ready the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33