If you want to retrieve stock quotes and crypto price data, you do not even need to leave your command line terminal. In this tutorial, we will show you how to use a Bash script to get stocks and crypto pricing on a Linux system.
In this tutorial you will learn:
- How to get stock and crypto price data using Linux command line
|Requirements, Conventions or Software Version Used
|Any Linux distro
|Bash, curl, jq
|Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Get stock and crypto price data using shell terminal on Linux
Follow the step by step instructions below to download the Bash script from GitHub and use it to retrieve the stock and crypto prices.
- Start by installing the prerequisite software packages. There’s a good chance that most systems already have these.
$ sudo apt update $ sudo apt install wget curl jq
- Next, download the Bash script from GitHub. You could use Git for this and clone the repo, but we will just retrieve it with the
$ wget https://raw.githubusercontent.com/evonshahriar/stock-cli/master/stock.sh
Here is a link to the GitHub page, in case you are interested.
- Make the script exectuable:
$ chmod +x stock.sh
- We are ready to retrieve some stock and crypto prices. Refer to Yahoo Finance to look up the the ticker or symbol that you want to get prices for.
$ ./stock.sh TSLA
- You can also look up prices for multiple symbols at once.
$ ./stock.sh TSLA DOGE-USD DAL AMC BTC-USD
- To keep a close eye on prices, we can use the
watchcommand to continuously update the output every second.
$ watch -n 1 -c ./stock.sh TSLA DOGE-USD DAL AMC BTC-USD
In this tutorial, we saw how to get stock and crypto price data via the command line terminal on a Linux system. Bash can be used for many powerful functions, and we have shown here how you do not even need to leave your shell terminal to get the latest quotes and pricing on stocks and cryptocurrencies.