Show HN: Mail me when the output of a command changes
github.com
github.com
diff2mail() {
a=$($@)
while true; do
b=$($@)
if [ "$a" != "$b" ]; then
echo "$a -> $b" | mail -s "$@ changed" 'root@example.com'
return
fi
sleep 1
done
}
diff2mail ls /tmp
And for a lot of stuff it's even shorter than that: make && x="is done" || x="has failed"; echo "build $x" | mail rootIs there something in particular, apart from generous amounts of gratuitous complexity, that you would like to point reader's attention at?