summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorBuildTools <unconfigured@null.spigotmc.org>2015-02-18 19:12:52 +0100
committerBuildTools <unconfigured@null.spigotmc.org>2015-02-18 19:12:52 +0100
commitbb2dd4b5f16bec5bf7e91c5a4baa517c0ab3ecf9 (patch)
tree3c806a64bf5426f9ecd0bed1922b38fd71d62ddd /util
parentdb6a39fff108f3e38ce9d01a52252655f6827abd (diff)
add currency.google
Diffstat (limited to 'util')
-rwxr-xr-xutil/bin/currency.google29
1 files changed, 29 insertions, 0 deletions
diff --git a/util/bin/currency.google b/util/bin/currency.google
new file mode 100755
index 00000000..694f7cc2
--- /dev/null
+++ b/util/bin/currency.google
@@ -0,0 +1,29 @@
+#! /bin/sh
+set -euf
+
+amount=$1
+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= sourcelanguage, 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=$amount&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 $*