Watch script

Published 3 weeks ago about unix, bash, ...

Here is simple “watch” script that is clearly performance ugly.

#!/bin/sh

DIR=$1
DIRMD5=`echo "$DIR"|md5`
DIRA=_WATCH_A_$DIRMD5
DIRB=_WATCH_B_$DIRMD5

touch /tmp/$DIRA
while true 
do
find $DIR | xargs ls -la | md5 > /tmp/$DIRA
diff /tmp/$DIRA /tmp/$DIRB || terminal-notifier -message "change $DIR"
cp /tmp/$DIRA /tmp/$DIRB 
sleep 1
done