Get the Core temp with lm-sensors

install sensors with:

apt-get install lm-sensors

for the average core temp use this:

sensors | grep "Core " | sed 's/+|°C//g;' | awk 'BEGIN{s=0;i=1;} {for (; i <= FNR; i++) s = s+$3 }; END { i--;print s/i }'

and max core temp:

sensors | grep "Core " | sed 's/+|.0°C//g;' | awk 'BEGIN{s=0;} {for (i = 1; i <= FNR; i++) if($3 > s){s = $3}; } END { print s }

Important is in sed to escape the ‘|’ in regex like ‘|’

2 thoughts on “Get the Core temp with lm-sensors”

  1. Hello, I enjoy reading all of your article post. I wanted to
    write a little comment to support you.

Leave a Reply

Your email address will not be published.

one × five =