Average CPU temperature
This is a one-liner to get the average CPU temperature using lm-sensors and Perl. Useful for status bars such as Dzen, commonly used in lightweight window managers.
sensors | perl -ne 'if (/^Core \d+:\s+\+(.*?)°C/) { $s += $1; $c++; } END { printf("%.1fC", $s/$c) }'
It averages the temperature readout for all available CPU cores.
Written by Ivan Mirić
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Perl
Authors
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/37922/32ef4e3e388cbadc756a008cade3ee6a.jpeg)
janosgyerik
25.16K
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/73304/b86a91c873215ee2357101f54047d8fe.jpeg)
Jean-Remy Duboc
12.25K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#