#66 Calculating Currency Values

A particularly interesting use of shell scripts is to offer a command-line currency conversion routine. This proves to be a two-part task, because the latest exchange rates should be cached, but that cache needs to be refreshed every day or two so that the rates stay reasonably up-to-date for the calculations.

Hence this solution is split into two scripts. The first script gets the exchange rate from CNN's money and finance website (http://money.cnn.com/) and saves it in a temporary cache file called .exchangerate. The second script provides the user interface to the exchange rate information and allows easy calculation of currency conversions.

The Code

 #!/bin/sh # getexchrate - Scrapes the current currency ...

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.