Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A "one-liner" for those without Lynx/Links' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A "one-liner" for those without Lynx/Links
Authored by: nicksay on Jul 08, '05 10:40:57AM
If you don't want to install one of the text-based browsers, here's a (long) "one-liner" you can stick in your .profile
currency() { curl -s "http://finance.yahoo.com/currency/convert?amt=$1&from=$2&to=$3" \
  | sed -n '28 p' | awk 'BEGIN {FS="</table>"} {print $12}' \
  | awk -v f=$2 -v t=$3 'BEGIN {FS="<td[^>]*>(<b>)?|(</b>)?</td>"} {print $17,f,"=",$23,t}'; }
It's split into multiple lines for display, but it should be one long line. The backslashes should allow for proper copy & pasting.

You can call it via: currency 1 USD EUR



[ Reply to This | # ]
A "one-liner" for those without Lynx/Links
Authored by: wallybear on Jul 11, '05 04:29:08AM

....funny, I tried something similar with awk, but the field separator (FS) variable considered only the first char of the string submitted, so I had to solve the problem in another way (some posts below).



[ Reply to This | # ]