I am outputting the HDD temps of my system to a text file on a local webserver that I can check every once in a while to monitor hdd temps when the system is under load. I was wondering if there is a way I can highlight if the temp is over a certain number. Here is a sample of the output I am getting (I'm piping it through column to arrange the columns nicely):
hddtemp -w /dev/sdg /dev/sdh /dev/sdi /dev/sda /dev/sdb | column -t -s ":"
/dev/sdg ST4000NM0033-9ZM170 46°C
/dev/sdh ST4000NM0033-9ZM170 44°C
/dev/sdi Hitachi HUA723030ALA641 43°C
/dev/sda ST4000NM0033-9ZM170 43°C
/dev/sdb Hitachi HUA723030ALA641 44°C
On the right where it shows the temp, I would like to make it red if it's over 50c. I am assuming there's a way to do it with grep, I'm just not sure if that's the only (or best) way to do it. And I'm not sure how to handle the '"dregee"C' part of it.
grepcolorize matches? or shall our code add color "by hand"? (2)grepis a tool to show matching lines and to filter out non-matching lines. Do you want to see all the lines? or only lines where it's over 50°C? (3) "Over 50" means "51 or above". Is "50 or above" acceptable? – Kamil Maciorowski Apr 06 '23 at 03:09