Re: bash doubt

2008-05-21 Thread Osamu Aoki
On Tue, May 13, 2008 at 08:05:16PM -0500, Jordi Gutiérrez Hermoso wrote: > On 13/05/2008, L. V. Gandhi <[EMAIL PROTECTED]> 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

Re: bash doubt

2008-05-16 Thread Bernardo Dal Seno
2008/5/15 L. V. Gandhi <[EMAIL PROTECTED]>: > Where am I wrong With the knowledge of the content of your files it is easier to answer. Running the script in trace mode is the best thing to do. Anyway, I see that there are two problems here (which may or may not be related to your problem): > fo

Re: bash doubt

2008-05-15 Thread Michelle Konzack
Am 2008-05-14 06:21:07, schrieb L.V.Gandhi: > I have a script as follows > [EMAIL PROTECTED]:~$ cat bin/getlstocks > #!/bin/bash > i=0 > while [ $i -ne 20 ] > do > for trv in $(cat temp) > do > i=$i+1 i=$((i+1)) Thanks, Greetings and nice Day M

Re: bash doubt

2008-05-15 Thread Javier Barroso
On Wed, May 14, 2008 at 3:05 AM, Jordi Gutiérrez Hermoso <[EMAIL PROTECTED]> wrote: > On 13/05/2008, L. V. Gandhi <[EMAIL PROTECTED]> 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 st

Re: bash doubt

2008-05-15 Thread Javier Barroso
On Thu, May 15, 2008 at 2:58 AM, L. V. Gandhi <[EMAIL PROTECTED]> wrote: > > Now I changed this to > rm -f ~/lstock > i=0 > for trv in $(cat temp) > do >while [ $i -ne 20 ] >do >i=$[i+1] >grep $trv stock/nsedata/2008/05/20080512.txt >> lstock >

Re: bash doubt

2008-05-15 Thread Ansgar Esztermann
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Where am I wrong By the way, you might want to call your script as bash -x scriptname This will run the script in trace mode, much facilitating debugging. You might also set PS4 to something sensible first. Personally, I prefer PS4='+$0 l $LI

Re: bash doubt

2008-05-14 Thread L . V . Gandhi
On Wed, May 14, 2008 at 8:54 AM, Todd A. Jacobs <[EMAIL PROTECTED]> wrote: > On Wed, May 14, 2008 at 06:21:07AM +0530, L.V.Gandhi wrote: > >> i=$i+1 > > This syntax is broken. Any of these alternatives will work: > >- let i=$i+1 >- let i+=1 >- i=$(( i + 1 )) > > Basicall

Re: bash doubt

2008-05-13 Thread Todd A. Jacobs
On Wed, May 14, 2008 at 06:21:07AM +0530, L.V.Gandhi wrote: > i=$i+1 This syntax is broken. Any of these alternatives will work: - let i=$i+1 - let i+=1 - i=$(( i + 1 )) Basically, you need to let bash know that $i is an integer, and not a string. -- "Oh, look: roc

Re: bash doubt

2008-05-13 Thread Douglas A. Tutty
On Tue, May 13, 2008 at 08:05:16PM -0500, Jordi Guti?rrez Hermoso wrote: > 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). Or Python. Or Ada. Almost anything but sh. Doug. -- To UNSUBSCRIBE, email to [EMAIL PRO

Re: bash doubt

2008-05-13 Thread Jordi Gutiérrez Hermoso
On 13/05/2008, L. V. Gandhi <[EMAIL PROTECTED]> 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 in

bash doubt

2008-05-13 Thread L . V . Gandhi
I have a script as follows [EMAIL PROTECTED]:~$ cat bin/getlstocks #!/bin/bash i=0 while [ $i -ne 20 ] do for trv in $(cat temp) do i=$i+1 grep $trv stock/nsedata/2008/05/20080512.txt >> lstock done done when I run I get error as integer expre