From b5f54440500bfa1e22590d8c921b10a127e103d1 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 28 Apr 2017 13:20:11 -0700 Subject: [PATCH] add new run when changed command --- run_when_changed | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 run_when_changed diff --git a/run_when_changed b/run_when_changed new file mode 100755 index 0000000..85c4c34 --- /dev/null +++ b/run_when_changed @@ -0,0 +1,14 @@ +#!/bin/sh + +WATCH_FILE="$1" +shift 1; + +WATCH_DIR=`dirname "$WATCH_FILE"` +WATCH_FILE=`basename "$WATCH_FILE"` + +inotifywait -m -e close_write,moved_to,create $WATCH_DIR | + while read -r directory events filename; do + if [ "x$filename" = "x$WATCH_FILE" ]; then + ( exec "$@" ); + fi; + done; -- 2.39.2