- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Printf bug?
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
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
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
01-20-2003 02:42 PM
01-20-2003 02:42 PM
I am having a problem with using printf in a script.
HR=08
printf "Hour: %02d\n" $HR
printf: Error converting 08
It works for 00 01 02 03 04 05 06 07 10 11 12. Is this a bug that I need to report to HP?
Thanks, Kris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2003 02:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2003 02:53 PM
01-20-2003 02:53 PM
Re: Printf bug?
string "08" to an integer using the usual C
language conventions; that is, a leading "0x"
means the number is in hexadecimal, and a
leading "0" means the number is in octal.
"8" is not a valid digit in an octal number.
You'll need to either strip off the leading 0
or use "typeset -i" to make ksh treat HR
as an integer.
typeset -i HR
HR=08
printf "Hour: %02d\n" $HR
Hour: 08
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2003 02:30 AM
01-21-2003 02:30 AM
Re: Printf bug?
There is a difference between /bin/sh and /usr/bin/ksh. I had to change the first line of my script from
#!/bin/sh
to
#!/usr/bin/ksh
I was doing
now=`date +%m%d`
time=$((now - 1))
and /bin/sh gives the wrong results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2003 03:40 AM
01-21-2003 03:40 AM
Re: Printf bug?
For details see e.g. patch text of PHCO_25597 (JAGad93413 and its special installation instructions).
Best regards...
Dietmar.