Skip to content

Instantly share code, notes, and snippets.

@KyleAMathews
Created May 12, 2011 01:00
Show Gist options
  • Save KyleAMathews/967731 to your computer and use it in GitHub Desktop.
Save KyleAMathews/967731 to your computer and use it in GitHub Desktop.
Run an arbitrary command on any changes to an arbitrary file
#!/bin/bash
# Usage: onchange.sh COMMAND FILE
# On Ubuntu/Debian, you'll need to install the inotify-tools package.
COMMAND=$1
FILE=$2
# Run once initially.
$command $file
while inotifywait "$FILE"; do
$COMMAND $FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment