#!/bin/bash
sd=(sda sdb sdc sdd)
out=""
COLUMNS=4
clear="\e[0m\e[39m"

my_target_temp=45
for i in "${!sd[@]}"; do
    temp=$(smartctl -a "/dev/${sd[$i]}" | grep Temperature_Celsius | grep 194 | awk '{print $10}' 2> /dev/null)
    color="\e[42m"
    if [ "$temp" -ge "${my_target_temp}" ]; then
        color="\e[41m"
    fi
    out+="${sd[$i]} \e[30m $color $temp°C $clear ,"
    c=${i+1}
    if [ $(((i+1) % COLUMNS)) -eq 0 ]; then
                out+="\n"
        fi
done
out+="\n"
echo -e "
HDD Temps:"
printf "$out" | column -c "$c" -ts $',' | sed -e 's/^/  /'
