[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: error in script



----- Original Message -----
From: "L.V.Gandhi" <lvgandhi@gmail.com>
Date: Thursday, September 4, 2008 9:50 pm
Subject: error in script
To: debian-user <debian-user@lists.debian.org>

> I have a script as follows
> #!/bin/bash
> rm -f ~/stock/flstock.csv
> grep FUTSTK ~/stock/today/$1 |grep "25/09/2008"|cut -s -d, -f9|sort -nr > temp
> i=0
> for trv in $(cat temp)
> do
>     grep $trv ~/stock/today/$1 >> ~/stock/flstock.csv
>     i=$((i+1))
>     if [ $i -eq 20 ]
>     then
>     exit 0
>     fi
> done   
> rm -f temp
> cat ~/stock/flstock.csv |cut -s -d, -f2|sort >> ~/stock/fliquidstocks.txt

> 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.

    - Dave


Reply to: