Re: error in script
On Fri, Sep 5, 2008 at 8:00 AM, David Parker <email@example.com
----- Original Message -----
From: "L.V.Gandhi" <firstname.lastname@example.org <mailto:email@example.com>>
Date: Thursday, September 4, 2008 9:50 pm
Subject: error in script
To: debian-user <firstname.lastname@example.org
> I have a script as follows
> rm -f ~/stock/flstock.csv
> grep FUTSTK ~/stock/today/$1 |grep "25/09/2008"|cut -s -d,
-f9|sort -nr > temp
> for trv in $(cat temp)
> grep $trv ~/stock/today/$1 >> ~/stock/flstock.csv
> if [ $i -eq 20 ]
> exit 0
> rm -f temp
> cat ~/stock/flstock.csv |cut -s -d, -f2|sort >>
> Last line is not getting executed . But if I run last line
afterwards in console, it works.
> Can someone throw somelight why it happens.
Try echoing the value of $i each time through the loop. I wonder if
the "exit 0" when $i = 0 is the problem.
Thanks. I think you are correct. What should do to come out of loop
instead of exiting the script.
If you only want the loop to run 20 times, then you can change it to
only read a maximum of 20 lines from the file:
for trv in $(head -n20 temp)
Integrated Information Technology Services
Registered Linux User #408177