使用 gcalccmd 在 Ubuntu 服务器中转换货币的命令

ful*_*der 3 server gcalctool calculator gnome-calculator

  1. 我可以gcalccmd像在 Ubuntu 桌面终端中使用一样在 Ubuntu 服务器中使用它吗?如果是,我可以使用命令转换货币吗gnome-terminalfinancal mode
  2. 如果是,转换货币的命令行是什么?(例如:1 美元兑换新元)

    2.1 货币兑换有限制吗?(例如:一天最多 100 次)

246*_*601 5

您可以从 Ubuntu 软件中心下载 qalculate。该应用程序允许您下载当前汇率并从命令行计算汇率。

$ sudo apt install qalc
$ qalc
> 1 GBP to euro
It has been 750 day(s) since the exchange rates last were updated.
Do you wish to update the exchange rates now? yes

  1 * GBP = approx. EUR 1.1756407

> 1 GBP to USD

  1 * GBP = approx. $1.3931343

> 
Run Code Online (Sandbox Code Playgroud)

然后,您可以使用终端中命令 lie 上的命令 exrates 更新速率。使用该工具时,请使用命令行帮助来查看各种可用命令。

$ qalc
> help

Enter a mathematical expression or a command and press enter.
Complete functions, units and variables with the tabulator key.

Available commands are:

approximate
assume ASSUMPTIONS
base BASE
delete NAME
exact
exrates
factor
find/list [NAME]
function NAME EXPRESSION
info
mode
partial fraction
save/store NAME [CATEGORY] [TITLE]
save definitions
save mode
set OPTION VALUE
expand
to/convert UNIT or "TO" COMMAND
variable NAME EXPRESSION
quit/exit

Commands for RPN mode:
rpn STATE
stack
clear stack
copy [INDEX]

move INDEX 1 INDEX 2
pop [INDEX]
rotate [DIRECTION]
swap [INDEX 1] [INDEX 2]

Type help COMMAND for more information (example: help save).
Type info NAME for information about a function, variable or unit (example: info sin).
When a line begins with '/', the following text is always interpreted as a command.

For more information about mathematical expression, different options, and a complete list of functions, variables and units, see the
relevant sections in the manual of the graphical user interface (available at http://qalculate.github.io/manual/index.html).
Run Code Online (Sandbox Code Playgroud)

您需要安装 qalc(但未运行),然后可以使用(例如)从命令行或脚本调用汇率:

1 GBP to EUR

您还可以使用qalc -t 1 GBP to EUR(-t = terse,与 verbose 相反),但也可以使用 awk 命令仅拆分值,如下所示:

awk -F' ' '{print $2}' <<< `qalc -t 500 GBP to EUR`

这将给出值 560.63584(按照给定的速率)