From 9949ce6fc51c37129c3b390a0715a8945cacc16a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 13 Sep 2017 11:43:19 +0200 Subject: add new scripts Signed-off-by: Florian Pritz --- onchange | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 onchange (limited to 'onchange') diff --git a/onchange b/onchange new file mode 100755 index 0000000..5326d17 --- /dev/null +++ b/onchange @@ -0,0 +1,30 @@ +#!/bin/bash + +declare -a files +declare -a command + +num_args=$# +parameters_done=0 +for (( i = 0; i < num_args; i++ )); do + case "$1" in + --) + parameters_done=1 + shift + ;; + *) + if ((parameters_done)); then + command+=("$1") + else + files+=("$1") + fi + shift + ;; + esac +done + +echo "files: ${files[*]}" +echo "command: ${command[*]}" + +while inotifywait -e close_write "${files[@]}"; do + "${command[@]}" +done -- cgit v1.2.3-24-g4f1b