#!/bin/bash # stockmon.sh - monitor any given stock market symbol via yahoo's financial services # Licensed under the terms of the GNU GPLv3 or later # Proprietary Software Must Perish! # AUTHOR: Johannes Truschnigg ( johannes.truschnigg@gmx.at || http://johannes.truschnigg.info ) [[ ${#} -eq 0 ]] && echo 1>&2 "Usage: ${0##*/} SYMBOL [DELAY]" && exit 1; STM_SYM="${1}"; STM_POS='\E[34m'; STM_NEG='\E[31m'; STM_QUOTE="NA"; while :; do STM_OLDQUOTE="${STM_QUOTE}"; STM_QUOTE=$(wget --quiet -O- "http://finance.yahoo.com/d/quotes.csv?s=${STM_SYM}&f=l1" || echo "NA"); STM_QUOTE="${STM_QUOTE%%?}"; if [[ ${STM_QUOTE/NA/0} < ${STM_OLDQUOTE/NA/0} ]]; then printf "%s: %s @ ${STM_NEG}%.2f-\n" "$(date)" "${STM_SYM}" "${STM_QUOTE}"; tput sgr0; elif [[ ${STM_QUOTE/NA/0} > ${STM_OLDQUOTE/NA/0} ]]; then printf "%s: %s @ ${STM_POS}%.2f+\n" "$(date)" "${STM_SYM}" "${STM_QUOTE}"; tput sgr0; else printf "%s: %s @ %.2f\n" "$(date)" "${STM_SYM}" "${STM_QUOTE}"; fi sleep ${2:-10}; done