Skip to content

Instantly share code, notes, and snippets.

@jmdugan
Last active December 19, 2015 10:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmdugan/5939116 to your computer and use it in GitHub Desktop.
Save jmdugan/5939116 to your computer and use it in GitHub Desktop.
ugly command line bitcoin latest
# to print High/Low/Last price from mtgox
# to get json_pp:
# described: http://manpages.ubuntu.com/manpages/raring/man1/json_pp.1p.html
# or cpan: http://search.cpan.org/~makamaka/JSON-PP-2.27103/bin/json_pp
# sudo apt-get install libjson-perl
# or use cpan
alias mtgox='curl -s -o - http://data.mtgox.com/api/2/BTCUSD/money/ticker'
function btc() { echo -n "Last, High, Low: "; mtgox | json_pp | grep -A5 "high\|low\|last\"" | grep y_s | sed -e 's/[ ]*//g' | sed -e 's/\"display_short\"//g' | tr -d "\n" ; echo "" ;}
@JulianTosh
Copy link

Thank you for json_pp. I did not know about this. Here's a slightly more efficient sed statement: curl -s -o - http://data.mtgox.com/api/2/BTCUSD/money/ticker | json_pp 2> /dev/null | grep -A5 "high|low|last"" | grep y_s | sed 's/.$([0-9.])".*/$\1/;' | paste - - -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment