#!/bin/bash file=/dev/shm/btc_stats fileURL=http://api.bitcoincharts.com/v1/weighted_prices.json function update_file { wget --quiet $fileURL -O $file #echo WILL_WGET } if [ -s $file ]; then #update if older than 1h age=`stat -c %Y $file`; now=`date +%s`; diff=$(($now - $age)); if [ $diff -gt 3600 ]; then update_file & #Do not hang the result fi; #Fucking ugly, but works content=`cat $file | python -mjson.tool | grep -A3 EUR | tail -n3 | cut -d':' -f2 | cut -d'"' -f2`; p24h=`echo "$content" | sed -n 1p | cut -d. -f1` p7d=`echo "$content" | sed -n 3p` p30d=`echo "$content" | sed -n 2p` graph=`sparklines $p30d $p7d $p24h` echo $graph [$p24h€] #dont want sparklines newline else update_file & #Will surely wait for iface fi