build script is able to detect file changes

This commit is contained in:
asus
2023-10-25 16:01:19 +02:00
parent 86c3309acf
commit 19fa992620

View File

@@ -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")