I am trying to create a bash script with 2 parameters:
I want to watch the
If you only need to check for files being created/deleted on top level (not checking subfolders) you might want to use the following.
It uses few ressources hence it can react quickly, I use it to check for a changed file.
#!/bin/bash
file="$1"
shift
tmp=$(mktemp)
trap 'rm "$tmp"' EXIT
while true; do
while [ ! "$tmp" -ot "$file" ]; do
sleep 0.5
done
eval "$@ &"
echo $! > "$tmp"
wait
done