Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Created December 20, 2012 17:06
Show Gist options
  • Save nicerobot/4346785 to your computer and use it in GitHub Desktop.
Save nicerobot/4346785 to your computer and use it in GitHub Desktop.
simple directory watching for new files.
#!/bin/bash
watch() {
touch .newer
while :; do
find . -type f -newer .newer \
| grep -v .newer \
| while read f; do
process_watch ${f}
touch .newer
done | processall_watches
sleep 1
done
}
process_watch() { echo $1; }
processall_watches() { cat; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment