Last active
May 19, 2018 15:33
-
-
Save categulario/7bcd194ddf958b803124083390203cfd to your computer and use it in GitHub Desktop.
Convierte pesos a dólares y de regreso desde la consola
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: usdtomxn 1 | |
# Output: 19.9319 | |
# Usage: mxntousd 19.9319 | |
# Output: 1.0 | |
# | |
# You'll need the jq command for this to run | |
# Vas a necesitar el comando jq para que esto jale | |
# | |
# https://stedolan.github.io/jq/ | |
usdtomxn() { | |
fix=$(curl -s -X POST http://www.banxico.org.mx/pubDGOBC_Sisfix-war/Sisfix_JSON | jq .tcfix | sed -E -e 's/^.//g' -e 's/.$//g') | |
if [[ $1 ]]; then | |
echo "$1 * $fix" | bc | |
else | |
echo $fix | |
fi | |
} | |
mxntousd() { | |
fix=$(curl -s -X POST http://www.banxico.org.mx/pubDGOBC_Sisfix-war/Sisfix_JSON | jq .tcfix | sed -E -e 's/^.//g' -e 's/.$//g') | |
if [[ $1 ]]; then | |
echo "$1 / $fix" | bc | |
else | |
echo $fix | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment