#!/bin/bash mapfile -t disks < <( ls /dev/sd[a-z] ) out="" dim="\e[43m" label="\e[1;30m" COLUMNS=3 clear="\e[0m\e[39m" my_target_temp=45 k=0 for i in ${disks[@]}; do temp=$(smartctl -a ${i} | grep Temperature_Celsius | grep 194 | awk '{print $10}' 2> /dev/null) color="\e[42m" ((k++)) if [ -z "$temp" ]; then out+="" else if [ "$temp" -ge "${my_target_temp}" ]; then color="\e[41m" fi out+="$(printf "${dim}${label} %s \e[30m$color %-17s," "$(echo ${i} | sed -e 's/\/dev\///')" "$temp $clear")" if [ $(($k % $COLUMNS)) -eq 0 ]; then out+="\n" fi fi done out+="\n" printf "\n HDD Temps:\n" printf "$out" | column -c $k -ts $',' | sed -e 's/^/ /'