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

178 Views Asked by At

i want to show my gpu temperature from a terminal command using my console on ubuntu 18.04.

I installed sensors-lm and finished the configuration.

When i type sensors -A radeon-pci-0100 in a terminal it shows me:

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

What i want is just the 36.0°C chars of this output, or better just 36°C.

How can i get this?

Thanks for help

2

There are 2 best solutions below

1
Cyrus On BEST ANSWER

Use -, + and ° as field separator. If row contains temp1: then print second column as integer and append °C:

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

Output:

36°C
1
s.ouchene On

try:

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

if you want to remove the + sign and leading spaces:

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