Plan 9 from Bell Labs’s /usr/web/sources/contrib/miller/rc/currency

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
date=()
switch ($1) {
case -help --help
  echo 'Usage: currency [-d mm/dd/yyyy] gbp cad # gives value of pound in $C'
  exit
case -d
  date=$2
  shift 2
}
switch ($#*) {
case 0
  xin=gbp
  xout=cad
case 1
  xin=gbp
  xout=$1
case *
  xin=$1
  xout=$2
}
xin=`{echo $xin|tr a-z A-Z}
xout=`{echo $xout|tr a-z A-Z}

switch ($#date) {
case 0
  now=`{date}
  months=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
  for (i in `{seq 1 12}) {
    if (~ $now(2) $months($i)) date=$i
  }
  date=$date^'/'^$now(3)^'/'^$now(6)
}
hget 'http://www.oanda.com/convert/classic?user=printable&exch='$xout'&expr='$xin'&value=1&date_fmt=us&date='$date | grep '^[ 	]*1 '

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].