質問

Hi I have the following list of stocks that is generated and it is placed in file called awk_1

dfs
fsd
dsf
sdf

I then run the following one liner which generates the correct ULR links

while read i ; do 
  echo $(http://uk.finance.yahoo.com/echartss=$i#symbol=$i\;range=my\;compare=\;indicator=volume\;charttype\=area\;crosshair\=on\;ohlcvalues\=0\;logscale\=off\;source\=undefined\;) tee stock_urls; 
done < awk_1 

However is does not put the out put in the file called stock_urls ?

Also it generate and strange output on the screen, below is a small section of the output that I get to standard output. It puts "./large_cap_stocks.sh: 51: ./large_cap_stocks.sh:" at the front and "not found" at the end , why might that be happening.

I have searching high and low for why this is not working any help would be really appreciated.

Thanks

役に立ちましたか?

解決

You probably meant to write like this:

while read i; do
    echo "http://uk.finance.yahoo.com/echarts?s=$i#symbol=$i\;range=my\;compare=\;indicator=volume\;charttype\=area\;crosshair\=on\;ohlcvalues\=0\;logscale\=off\;source\=undefined\;"
done < awk_1 | tee stock_urls

That is:

  • In the echo command, use "..." to quote your text instead of $(...) which is something else
  • Use the pipe operator | to pass the output to tee, and you can pipe the entire loop this way, no need to do for individual echo lines.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top