#!/bin/bash update_db() { local src=$1 local dst=$2 while read line ; do if [[ -z $(echo "${line}" | sed -re 's/(^#.*|^\w*$)//') ]]; then echo "${line}" >> "${dst}" fi id=$(echo "${line}" | grep -o '"[^"]*"') grep "${id}" "${dst}" 2>&1 >/dev/null || echo "${line}" >> "${dst}" done < "${src}" } die() { echo "$*" exit 1 } cd /usr/share/hddtemp wget http://download.savannah.nongnu.org/releases/hddtemp/hddtemp.db -O hddtemp.db -q || die "Failed to download new hddtemp.db file" update_db "hddgentoo.db" "hddtemp.db"