从一行中查找数字并获得商

imp*_*nin 3 text-processing

Digital_A803x_433Mbps用户:(共发放2784张牌照;使用中共314张牌照)

在上面的示例文本行中,我想获得可用许可证的百分比,因此输出将是:88.27%,这是使用中的许可证和颁发的许可证的商:(314/2784) * 100 - 100。

Ste*_*itt 7

使用 AWK:

$ echo 'Users of Digital_A803x_433Mbps: (Total of 2784 licenses issued; Total of 314 licenses in use)' |
awk '{ printf "%2.2f%%\n", 100 - $11 / $6 * 100 }'
88.72%
Run Code Online (Sandbox Code Playgroud)

这假设标签中没有空格(“Digital_...”)。