#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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.