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

Re: error in script



L.V.Gandhi:
>
> #!/bin/bash
> rm -f ~/stock/flstock.csv
> grep FUTSTK ~/stock/today/$1 |grep "25/09/2008"|cut -s -d, -f9|sort -nr >
> temp

You really shouldn't use "temp" as a name. See 'man mktemp'.

> i=0
> for trv in $(cat temp)
> do

You could save this use of cat with this idiom:

while read trv; do
    # do sth. with trv
done < temp

This iterates over the lines of the file "temp" and assigns each line to
trv. It behaves differently from your version in case one or more lines
in "temp" contains whitespace, though.

>     grep $trv ~/stock/today/$1 >> ~/stock/flstock.csv
>     i=$((i+1))
>     if [ $i -eq 20 ]
>     then
>     exit 0

You probably want to "break" out of the loop. Exit exits the shell.

>     fi
> done
> rm -f temp
> cat ~/stock/flstock.csv |cut -s -d, -f2|sort >> ~/stock/fliquidstocks.txt

Useless use of cat. :)

J.
-- 
If nightclub doormen recognised me I would be more fulfilled.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>

Attachment: signature.asc
Description: Digital signature


Reply to: