On Wed, May 14, 2008 at 3:05 AM, Jordi Gutiérrez Hermoso <jordigh@gmail.com> wrote:
On 13/05/2008, L. V. Gandhi <lvgandhi@gmail.com> 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.