1
0
Files
www.erictaylor.me/watch-and-run.sh
2025-11-22 09:40:19 -05:00

23 lines
613 B
Bash

#!/bin/bash
# Configuration
FILE_TO_WATCH="content/index.md" # Replace with the file you want to monitor
SCRIPT_TO_RUN="convert.sh" # Replace with the script you want to run
# Check if the files exist
if [ ! -f "$FILE_TO_WATCH" ]; then
echo "Error: File '$FILE_TO_WATCH' not found."
exit 1
fi
if [ ! -x "$SCRIPT_TO_RUN" ]; then
echo "Error: Script '$SCRIPT_TO_RUN' is not executable."
exit 1
fi
# Use inotifywait to monitor the file for changes
while inotifywait -q -e modify "$FILE_TO_WATCH"; do
echo "File '$FILE_TO_WATCH' has been modified. Running '$SCRIPT_TO_RUN'..."
$SCRIPT_TO_RUN
done