LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash stock quotes with curl (https://www.linuxquestions.org/questions/programming-9/bash-stock-quotes-with-curl-917399/)

calix333 12-06-2011 09:45 AM

Bash stock quotes with curl
 
Hi,

I am trying to write a script that I will allow to run continually monitoring stock quotes sourced from yahoo finance.

My problem is how to compare prices each time they are retrieved so I can format them appropriately, e.g. red text for decrease in price green text for increase/no-change.

My code so far:

Code:

#/bin/bash

while x=0; do 
val=`curl -s http://download.finance.yahoo.com/d/quotes.csv?\s\=BARC.L\&\f\=l1`
echo -e "\033[32m$val\033[0m";
val2=`curl -s http://download.finance.yahoo.com/d/quotes.csv?\s\=BARC.L\&\f\=l1`
if [ $val2 -lt $val ]; then
  #prints in red indicating price fall
  echo -e "\033[33m$val2\033[0m";
fi
sleep 5;
done

I would appreciate some input.

Thanks


All times are GMT -5. The time now is 04:47 AM.