#67 Tracking Your Stock Portfolio

A more complex task for the shell is to keep track of the overall value of your stock portfolio. While this might actually be too depressing to see each time you log in, the building blocks are quite informative and valuable on their own.

Like Script #66, this solution is built from two different scripts, one that extracts the most recently traded value of a given stock, and a second script that reads and calculates running totals for a portfolio of stocks.

The Code

 #!/bin/sh # getstock - Given a stock ticker symbol, returns its current value # from the Lycos website. url="http://finance.lycos.com/qc/stocks/quotes.aspx?symbols=" if [ $# -ne 1 ] ; then echo "Usage: $(basename $0) stocksymbol" >&2 exit ...

Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.