下面是一个脚本片段,该脚本生成具有用户选择长度的随机密码。我已经让脚本作为一个图形用户界面完美运行。
我想添加一些额外的功能,在脚本的底部是一些用户信息
The passwords generated by this application are very strong, here is an example of the strength you can achieve by using this application;

Length of Password:
$newnumber

Character Combinations:
${#matrix}

Calculations Per Second:
4 billion

Possible Combinations:   2 vigintillion

Based on an average Desktop PC making about 4 Billion calculations per second it would take about 21 quattuordecillion years to crack your password.
As a number that's 21,454,815,022,336,020,000,000,000,000,000,000,000,000,000,000 years!"

我怎么才能让巴什计算出
`21 quattuordecillion years`


Length of Password:
$newnumber

Character Combinations:
${#matrix}

Calculations Per Second:
4 billion

Possible Combinations:   2 vigintillion

最佳答案

从bash进行数学计算的一个简单方法是使用bc命令行计算器。
下面是如何从bash脚本调用它:

answer=$(bc << LIMIT_STRING
your math operations here
LIMIT_STRING
)

关于linux - 在bash脚本中进行数学运算,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25516852/

10-13 09:07
查看更多