17 lines
481 B
Bash
17 lines
481 B
Bash
#!/bin/bash
|
|
|
|
# Define the file to watch
|
|
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
|
|
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")
|
|
|