#!/bin/bash # Check if the correct number of arguments is passed if [ "$#" -ne 3 ]; then echo "Usage: $0 " exit 1 fi # Assign arguments to variables FILE_TO_WATCH=$1 PROCESS_NAME=$2 COMMAND_TO_RUN=$3 eval "$COMMAND_TO_RUN" & # Watch the file for changes while inotifywait -e modify "$FILE_TO_WATCH"; do # Kill the process sudo pkill "$PROCESS_NAME" # Run the provided command (like build and run) eval "$COMMAND_TO_RUN" & done