From 19fa992620d80c3a170612e6afbbba271295b5db Mon Sep 17 00:00:00 2001 From: asus Date: Wed, 25 Oct 2023 16:01:19 +0200 Subject: [PATCH] build script is able to detect file changes --- build.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index a992296..36f865e 100644 --- a/build.sh +++ b/build.sh @@ -3,18 +3,14 @@ # Define the file to watch file_to_watch="./" - -## Watch for modification events on the file continuously -#inotifywait --monitor --event modify "$file_to_watch" | tee /dev/tty -#while read -r directory events filename; do -# echo "The file $filename was modified." -# # Add your desired actions here -#done - -#inotifywait --monitor --event modify --format '%w %e %f' "$file_to_watch" - - +# Watch for modification events on the file continuously, with a minimum interval of 1s +last_modified=0 while read -r directory events filename; do - echo "The file $filename was modified." - # Add your desired actions here -done < <(inotifywait --monitor --event modify "$file_to_watch") + current_time=$(date +%s) # Get the current time in seconds + + if [ "$current_time" -gt "$last_modified" ]; then + last_modified=$current_time + echo "$current_time - The file $filename was modified." + fi +done < <(inotifywait -q --monitor --event modify "$file_to_watch") +