From 02290df022a90b9d456a2571616e897e7de091b2 Mon Sep 17 00:00:00 2001 From: Ken Chou Date: Fri, 2 Feb 2024 15:19:13 +0800 Subject: [PATCH] monitor --- monitor-dir.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 monitor-dir.sh diff --git a/monitor-dir.sh b/monitor-dir.sh new file mode 100755 index 0000000..b9f4c4a --- /dev/null +++ b/monitor-dir.sh @@ -0,0 +1,12 @@ +#!/bin/bash +if [[ -z $1 ]]; then + echo "Usage:" $(basename $0) "[PATH...]" + exit 1 +fi + +BIN_PATH=$(dirname $0) +inotifywait --exclude '(.tmp)' -r -me moved_to "$@" | while read dir action file; do + echo "The file '$file' appeared in directory '$dir' via '$action'" + # do something with the file + ${BIN_PATH}/file-clean-rust --prune "${dir}/${file}" +done