This is a discussion on bash doubt within the Debian Linux Users forum forums, part of the Debian Linux category; --> On Tue, May 13, 2008 at 08:05:16PM -0500, Jordi Gutiérrez Hermoso wrote: > On 13/05/2008, L. V. Gandhi <lvgandhi@gmail.com> ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Tue, May 13, 2008 at 08:05:16PM -0500, Jordi Gutiérrez Hermoso 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]. Although it should work.... why not use POSIX style which bas accept too. i=$((i+1)) For speed of shell script, it is faster to use dash and better to be portable. > Btw, an easier way to do a for loop of this sort in bash is to do "for > i in `seq 20`" (notice the backticks). Yep. I agree. Also with xargs command instead of shell loop, you should get faster script. > If you want to do a lot of text manipulation, it may feel more natural > to use Perl (or at least it feels more natural to me). True. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |