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