Trick: Currency Converter on Command Line

7:59 AM

Hello, today I'd like to show you a simple trick to have simple currency converter on Linux command line. I hope this post is useful for you especially for those who often works with international sales or trading. Here is a working example.


It uses Google Finance service to work, please make sure you are connected to the Internet when using it. Now, please open ".bashrc" file using your favorite text editor. If you use Gedit, simply type the following command to open it:
  • gedit ~/.bashrc
Create new line at the end of the file, and put this code:
  • currency_convert() {
  • curl -s "http://www.google.com/finance/converter?a=$1&from=$2&to=$3" | sed '/res/!d;s/<[^>]*>//g';
  • }
After editing, ".bashrc" file should looks like this:


Save the changes and close the text editor. Now, open Terminal and type the following command to apply the changes you've made:
  • source ~/.bashrc
Done! Now, you can use simple currency converter by typing:
  • currency_convert 1 usd eur
The above command convert 1 US Dollar into Euro. Please change the code to suit your needs.

Enjoy :)

0 comments:

Post a Comment