You could try:
nohup nc bitcoincharts.com 27007 |awk '/mtgoxUSD/ {gsub(/,/,"");p = $4+0;v = $6+0;print $2" "p" "v}' >>/tmp/stream.out &
Output in stream.out will look like:
1312824328 7.67 0.64291525
1312824328 7.667 3.5
1312824328 7.66051 7
1312824328 7.66 41.65206919
1312824328 7.65766 10.03
1312824329 7.65755 0.08
1312824329 7.65 20
1312824329 7.65 5
1312824329 7.65 2
1312824329 7.65 16.3761626
(trade time in epoch, value in USD, and volume)
Then something like (pardon my rusty mysql, but just showing the general idea... )
while true
do
# take a snapshot
tail -1 stream.out > /tmp/stream.out.tmp
TIME=$(cat /tmp/stream.out.tmp |awk '{print $1}')
TRADE=$(cat /tmp/stream.out.tmp |awk '{print $2}')
QTY=$(cat /tmp/stream.out.tmp |awk '{print $3}'
mysqlupdate=`(mysql -u user -p password -e "INSERT INTO blah.blah VALUES ($TIME,$TRADE,$QTY)") 2>&1`
sleep 2
done