![](https://seccdn.libravatar.org/avatar/ee738d4e31faf58ee5b06d27af86a6f9.jpg?s=120&d=mm&r=g)
Hello, On Wed, 17 Jun 2009, David C. Rankin wrote:
#!/bin/bash for i in $(cat /proc/partitions | egrep sd[abcdefgh]$ | sed -e 's/^.*s/s/');
Useless use of cat. Useless use of (e)grep. sed can do all that. sed '/sd[a-h]$/{s/^.*s/s/';}' /proc/partitions or even better: ==== for device in \ $( awk '$4 ~ /^[sh]d[a-z]$/{print $4;}' /proc/partitions ); \ do \ echo "/dev/${device}"; \ done ==== backslashes and semicolons added for easy copy & paste use ==== which should work with plain old IDE, SATA, and both with libata. And assuming (won't boot the new box for this now), that the device is still field 4 in /proc/partitions on current 2.6 kernels.
do hddtemp /dev/$i done
I use a little script directly calling smartctl. ==== BEGIN { i=0; while ( getline < "/proc/partitions" ) { if( $4 ~ /^[sh]d[a-z]$/ ) {devs[i++]=$4;} } for(d in devs) { sc="smartctl -d ata -A /dev/" devs[d]; mf = "/proc/ide/" devs[d] "/model"; getline model < mf; while( sc | getline) { if( $1 == 194 || $2 ~ /emper/ ) { printf "%s: %d °C [%s]\n", devs[d], $10, model; break; } } } } ==== BTW: it'd be no problem converting the temperature from °C to °F within that one awk -- and even adding an option for that ;) -dnh, planning to look into what 'hddtemp' actually does internally -- We all know Linux is great... it does infinite loops in 5 seconds. -- Linus Torvalds -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org