M BUZZ CRAZE NEWS
// general

Only view the CPU temperature from command `sensors`

By Daniel Rodriguez

Ok, so when I run the command:

sensors

I get a truck load of info:

atk0110-acpi-0
Adapter: ACPI interface
Vcore Voltage: +1.16 V (min = +0.85 V, max = +1.60 V) +3.3 Voltage: +3.39 V (min = +2.97 V, max = +3.63 V) +5 Voltage: +5.17 V (min = +4.50 V, max = +5.50 V) +12 Voltage: +12.36 V (min = +10.20 V, max = +13.80 V)
CPU FAN Speed: 1906 RPM (min = 600 RPM)
CHASSIS FAN Speed: 0 RPM (min = 600 RPM)
CPU Temperature: +31.0°C (high = +60.0°C, crit = +95.0°C)
MB Temperature: +32.0°C (high = +45.0°C, crit = +95.0°C)

What would the command be if I just wanted to see this:

CPU Temperature: +31.0°C (high = +60.0°C, crit = +95.0°C)

or better yet, just this:

CPU Temperature: +31.0°C 

3 Answers

You can process the output of sensors command with grep and/or cut to format it the way you want.

To get only the line reporting the CPU temperature you can use this (including the high and critical limits):

sensors | grep -A 0 'CPU T' 

The following will give you only the temperature (with the °C suffix) :

sensors | grep -A 0 'CPU T' | cut -c18-25

This will give the output as you indicated at the end of your question:

sensors | grep -A 0 'CPU T' | cut -c1-25
4

The string below should work for you. grep -A[4] gives the next 4 lines The watch -d refreshes the changes and -d highlights the difference from the last refresh.

watch -d 'sensors | grep 'CPU Temperature''

Install the small apci package with the following command:

sudo apt-get install acpi

You will need to press Y for confirmation for the first time.

Now to find the CPU temperature with this command:

acpi -t

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy