Skip to content

Instantly share code, notes, and snippets.

@abemassry
Created October 6, 2013 01:11
Show Gist options
  • Save abemassry/6848070 to your computer and use it in GitHub Desktop.
Save abemassry/6848070 to your computer and use it in GitHub Desktop.
watch a file for changes and log to logfile
#!/bin/bash
while [ 1 ]; do
before=`cat $1`
sleep 1
after=`cat $1`
if [ "$before" != "$after" ]; then
today=`date`
echo "$1 changed on: $today" >> logfile.log
echo "$1 changed on: $today and logged"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment