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

Re: script doubt

On Fri, Mar 28, 2008 at 08:11:37AM +0530, L.V.Gandhi wrote:
> I have a scipt as follows.
> #!/bin/bash
> cd /home/lvgandhi/stock
> tf=modbhav
> rm -f AngelGoldPrice
> for symbol in $(cat AngelGoldHoldings.txt)
> do
> grep "$symbol,"  $tf >> AngelGoldPrice
> done
> in the forloop if I put echo $symbol, i get all the lines of file
> AngelGoldHoldings.txt. Each line in this file has a word without space
> all letters. modbhav dfile exists in /home/lvgandhi/stock. It contains
> lines having symbol and other parameters in addition to other lines.
> But I get empty file AngelGoldPrice. Where am I going wrong?

It looks ok to me, as described, so just try breaking the problem
down to see where it's going wrong.  I'd probably first remove the
redirection after grep and run it until you see the expected output,
with various tweaks applied.  The quotes on the grep pattern are likely
not necessary, since you say the lines contain no spaces, but they don't
look like they'd cause a problem.  Try grep $symbol directly, omitting
the comma, etc., etc..    Try grepping for some symbols manually.
Maybe there are non-printing (i.e., hidden) characters in the file?


Ken Irving, fnkci+debianuser@uaf.edu

Reply to: