scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

commit 2020d7fff6a92c733343ed33ac531105bb14444e
parent 35cbd6418275d716ec566c9a28c0bbca6e2ca96b
Author: gearsix <gearsix@tuta.io>
Date:   Fri, 26 Aug 2022 10:36:31 +0100

added nix/onfilech

Diffstat:
Anix/onfilech.sh | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/nix/onfilech.sh b/nix/onfilech.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh +# on file change +# description: when a file ($1) modified time is updated, perform $2.. +# dependencies: stat +# e.g.$ onfilech draft-plans.txt cp draft-plans.txt new-plans.txt + +file=$1; shift +cmd=$* + +while true; do + mod=$(stat "$file"); + while [ "$mod" != false ]; do + upd=$(stat "$file"); + if [ "$upd" != "$mod" ]; then + $cmd; echo update; mod=false; + fi; + sleep 10; + done; +done;