#!/bin/bash # # Monitor the input directory and if any change occurs run the provided command: # # Usage: # after-change.sh /tmp ls -al %f if [ $# -lt 3 ]; then echo "Usage: $0 dir cmd " exit 1 fi which inotifywait 2>&1 >/dev/null if [ "$?" == "1" ]; then echo "ERROR: inotifywait not installed." exit 1 fi dir=$1 shift cmd=$1 shift options=$* inotifywait -q -r -m $dir $options eval $cmd