#!/bin/bash DRIVEPATH="$1" INFO="$(sudo smartctl -a $DRIVEPATH)" TEMP=$(echo "$INFO" | grep '194 Temp' | awk '{print $10}') if [[ $TEMP == '' ]]; then TEMP=$(echo "$INFO" | grep '190 Airflow' | awk '{print $10}') fi if [[ $TEMP == '' ]]; then TEMP=$(echo "$INFO" | grep 'Temperature Sensor 1:' | awk '{print $4}') fi if [[ $TEMP == '' ]]; then TEMP=$(echo "$INFO" | grep 'Current Drive Temperature:' | awk '{print $4}') fi if [[ $TEMP == '' ]]; then TEMP=$(echo "$INFO" | grep 'Temperature:' | awk '{print $2}') fi echo $TEMP # https://askubuntu.com/questions/1426482/tool-to-monitor-hdd-temperature-in-ubuntu-server-22-04 # ./gethddtemp.sh /dev/sda