Search code examples
bashubuntucommand-linesensorslm-sensors

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


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


Solution

  • 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