- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script to output yesterday's day of the month
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
тАО11-02-2009 04:56 AM
тАО11-02-2009 04:56 AM
Script to output yesterday's day of the month
I need to output yesterday's day of the month. But, I need it to print out as "01" not "1". Presently I do: d=`expr $(date +%d) - 01` but all this does is prints out a 1. I need a 01.
Thanks,
- Tags:
- date
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 05:21 AM
тАО11-02-2009 05:21 AM
Re: Script to output yesterday's day of the month
Check out the man page on printf.
Here is an example of formatted output.
ipcs | awk '{total=total+$5};END {printf "%6.3f\n",total/1024/1024/1024 }'
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 05:24 AM
тАО11-02-2009 05:24 AM
Re: Script to output yesterday's day of the month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 05:35 AM
тАО11-02-2009 05:35 AM
Re: Script to output yesterday's day of the month
typeset -Z2 d=$(( $(date +%d) - 1 ))
Of course this doesn't work too well on the first or the first of the year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 06:11 AM
тАО11-02-2009 06:11 AM
Re: Script to output yesterday's day of the month
# echo `(export TZ=XYZ+24; date "+%Y-%m-%d")`
Look here for more :)
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=9251
Best regards
Fredrik Eriksson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 07:38 PM
тАО11-02-2009 07:38 PM
Re: Script to output yesterday's day of the month
If you look a litter further, you'll find this is not supported, safe nor work all the time.
And you can simplify it to just:
TZ=XYZ+24 date "+%Y-%m-%d"