# before running the script, do: # mkfifo trigger # echo foo > value # from another shell, run: # echo 124 > value; echo > trigger read curval < valuewhile true; do while read triggerline; do read newval < value if [ "x$newval" != "x$curval" ]; then echo "value has changed to '$newval'" curval="$newval" # fork off child which observes changes until after the # parent is listening trigger again { sleep 2 read val < value if [ "x$newval" != "x$curval" ]; then echo > trigger fi } & fi done < trigger echo "sender has closed pipe, reopening"done