« Return to Thread: bash doubt

Re: bash doubt

by Javier Barroso-3 :: Rate this Message:

Reply to Author | View in Thread



On Wed, May 14, 2008 at 3:05 AM, Jordi GutiƩrrez Hermoso <jordigh@...> wrote:
On 13/05/2008, L. V. Gandhi <lvgandhi@...> wrote:
> I have a script as follows
[snip]
>                 i=$i+1
[snip]
>  How to correct it

Your counter is wrong. $i + 1 means to treat i as a string and to
append the string "1" to it. If you want to do arithmetic in bash, you
have to put it inside brackets. i = $[i+1].
 
You should use i=$((i+1))

In man bash:
 The old format $[expression] is deprecated and will be removed in upcoming versions of bash.

 « Return to Thread: bash doubt

LightInTheBox - Buy quality products at wholesale price