在 ubuntu 终端上显示没有 labels/text 和 "sensors" 的温度?

Show temperature without labels/text with "sensors" on ubuntu terminal?

我想在 ubuntu 18.04 上使用我的控制台通过终端命令显示我的 gpu 温度。

我安装了sensors-lm并完成了配置。

当我在终端中输入 sensors -A radeon-pci-0100 时,它会显示:

radeon-pci-0100
temp1:        +36.0°C  (crit = +120.0°C, hyst = +90.0°C)

我想要的只是此输出的 36.0°C 个字符,或者更好的是 36°C.

我怎样才能得到这个?

感谢帮助

尝试:

sensors -A radeon-pci-0100 | grep temp1 | cut -d ':' -f 2 | cut -d '(' -f 1

如果要删除 + 符号和前导空格:

sensors -A radeon-pci-0100 | grep temp1 | cut -d ':' -f 2 | cut -d '(' -f 1 | tr -d '+' | tr -s ' '

使用 -+° 作为字段分隔符。如果行包含 temp1: 然后将第二列打印为整数并附加 °C:

awk -F '[-+°]' '/temp1:/ {printf("%d°C\n",)}' file

输出:

36°C