Increment counter in ksh

Hello,

I am making an increment counter in ksh. So i write a number in a temporary file and when I execute my script I read this file and I make +1.

But how can I make this with a number with 6 digits , example
000009 + 1 = 000010
...
....
....
000099 + 1 = 000100

Do anyone know where I can make this ????

PS : I have also use the ltrim function in ksh but the syntaxe was not good. Perhaps I little help for this function.

Thanks a lot....

Try this...

typeset -Z6 number
number=9
echo $number
((number=number+1))
echo $number
exit 0
2 Likes

Hello,

Thanks for you little code , it's work funny...

Thanks and bye...

Hi,

OK and how is it possible if you have to increment on 10 digits.

I tried with typeset -Z10 number.

but doesn't work.

Many thanks for answering.

liliput

What output are you seeing? The code works fine here. Are you sure your are executing in ksh? ie, specifying the shell?

#!/bin/ksh

typeset -Z10 number
number=9
echo $number
((number=number+1))
echo $number
exit 0

Cheers,

Keith

Hi Keith,

Many thaks for answering.

you're right. it works fine.

MAny thanks.