build script is able to detect file changes
This commit is contained in:
24
build.sh
24
build.sh
@@ -3,18 +3,14 @@
|
|||||||
# Define the file to watch
|
# Define the file to watch
|
||||||
file_to_watch="./"
|
file_to_watch="./"
|
||||||
|
|
||||||
|
# Watch for modification events on the file continuously, with a minimum interval of 1s
|
||||||
## Watch for modification events on the file continuously
|
last_modified=0
|
||||||
#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"
|
|
||||||
|
|
||||||
|
|
||||||
while read -r directory events filename; do
|
while read -r directory events filename; do
|
||||||
echo "The file $filename was modified."
|
current_time=$(date +%s) # Get the current time in seconds
|
||||||
# Add your desired actions here
|
|
||||||
done < <(inotifywait --monitor --event modify "$file_to_watch")
|
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")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user