printf bad ?

Jason Shein jason-xgs8i/e9EeWTtA8H5PvdGCwD8/FfD2ys at public.gmane.org
Fri Mar 18 20:44:30 UTC 2005


On March 18, 2005 08:14 pm, Peter wrote:
> Hi,
>
> can someone please try this out:
>
> printf "%05d" 08
>
> it says 'invalid number' for any number of 0's before the 8. Why does it
> think it's octal ?! Both the shell version and the executable have the
> same problem, so I guess it's a shell problem. This also explains
> problems I had some time ago composing a shell script on this machine
> (I started a thread on this list about that - some numbers used to
> disappear for no reason - the numbers were sequential filename in aa
> script).
>
> Again:
>
> /usr/bin/printf "%05d" 08
> /usr/bin/printf: 08: value not completely converted
>
> printf "%05d" 08
> -bash: printf: 08: invalid number
>
> printf "%05d" 10#08
> -bash: printf: 10#08: invalid number
>
> (according to the bash manual that notation should force decimal - it
> does not - not in quotes and not in ticks and not with a
> backslash-escaped '#').
>

Take a look here 
http://colton.byuh.edu/courses/tut/printf.pdf

printf "%05d",08  produces    00000,08
printf "%05d",8    produces    00000,8
printf "%05d"8     produces    0000008
printf "%05d".8    produces    000000.8


-- 
Jason Shein
Director of Networking, Operations and Systems
Detached Networks
jason-xgs8i/e9EeWTtA8H5PvdGCwD8/FfD2ys at public.gmane.org
( 905 ) - 876 - 4158 Voice
( 905 ) - 876 - 5817 Mobile
http://www.detachednetworks.ca
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list