What is is a Winkdex bitcoin price script written in bash for use in your linux command-line environment.

Simply run to get the most current price:

$ The price for one bitcoin as of 07:38:30 PM is $418.46. [WINKDEX.COM]

Build Process for

  1. Choose a Bitcoin price index to use. Options include:
  2. Consult its API documentation (WinkDex in this case).
  3. In Linux terminal do: vim
  4. Add bash shebang header: #!/bin/bash.
  5. Pull down data: curl (URL for API calls, from WinkDex get current 'cents' value of 1.0 BTC).
  6. Convert cents value to #dollars/BTC: cut (with space delimiters, cents data only), use bc to calculate ($cents * 0.01).
  7. Add time, default message to print: date -time-flags plus The price of one bitcoin is $[$dollars] as of [$time].

The Script:


# Bitcoin price script using WINKDEX API (
# WARNING: Run no more than once per minute.

# get current BTC price in cents, log to wink.log

curl -s -H “User-Agent: wink-sh” “" > $HOME/bin/wink.log

# cut and print BTC value in ‘cents’, log to cents.log

cat $HOME/bin/wink.log | cut -d “:” -f 5 | cut -d “,” -f 1 > $HOME/bin/cents.log

# set variable PRICE and calculate dollars and cents using ‘bc’

PRICE=$(echo “`cat $HOME/bin/cents.log` * .01” | bc)

# print PRICE along with current time and attribution

echo “The price for one bitcoin as of `date +\”%r\”` is \$$PRICE. [WINKDEX.COM]”

rm $HOME/bin/wink.log && rm $HOME/bin/cents.log

See on GitHub.

Planned Improvements:

  1. Replace log files with argument variables.
  2. Color the outputs/output text.
  3. Set to auto-refresh each minute in terminal while running.
  4. Request extra bandwidth from Winkdex to reduce refresh interval to 10 seconds.