January 2004
Intermediate to advanced
368 pages
7h 25m
English
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.
#!/bin/sh # getexchrate - Scrapes the current currency ...
Read now
Unlock full access