Get stock and crypto price data using shell terminal on Linux

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
Get stock and crypto price data using shell terminal on Linux
Get stock and crypto price data using shell terminal on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software Bash, curl, jq
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – 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.

  1. 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
    
  2. 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 command.
    $ wget https://raw.githubusercontent.com/evonshahriar/stock-cli/master/stock.sh
    

    Here is a link to the GitHub page, in case you are interested.

  3. Make the script exectuable:
    $ chmod +x stock.sh
    
  4. 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
    
  5. You can also look up prices for multiple symbols at once.
    $ ./stock.sh TSLA DOGE-USD DAL AMC BTC-USD
    
    Retrieving multiple stock prices at once with Bash script
    Retrieving multiple stock prices at once with Bash script
  6. To keep a close eye on prices, we can use the watch command to continuously update the output every second.
    $ watch -n 1 -c ./stock.sh TSLA DOGE-USD DAL AMC BTC-USD
    

Closing Thoughts




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.



Comments and Discussions
Linux Forum