From 67a7a6a6beeae2b36de38c4dd59d4895b6a188bc Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 5 Mar 2015 17:16:19 +0100 Subject: utils: normalize naming of google wrappers --- util/bin/google.currency | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 util/bin/google.currency (limited to 'util/bin/google.currency') diff --git a/util/bin/google.currency b/util/bin/google.currency new file mode 100755 index 00000000..8219a866 --- /dev/null +++ b/util/bin/google.currency @@ -0,0 +1,28 @@ +#! /bin/sh +set -euf + +tc=${TC:="usd"} +sc=${SC:="eur"} + +usage(){ + echo 'TC= targetcurrency, valid strings are in the style of "usd", "eur" or "sgd". default "usd"' + echo 'SC= sourcecurrency, same TC, default is eur' + echo 'Example: TC="sgd" ./currency.google 11' + + exit 0 +} + +currency_convert(){ + text=$* + url="http://www.google.com/finance/converter?a=$1&from=$sc&to=$tc" + curl -A "Mozilla/5.0" -Ss "$url" | + sed '/res/!d;s/<[^>]*>//g' | + #sed 's/\[\[\[\"//' | + awk '{print $4}' +} + +if [ $# -eq 0 ]; then + usage +fi + +currency_convert $* -- cgit v1.2.3