watchfolder & execute on change

Short script to execute some commend when folder changes.

:~$ cat bin/watchfolder 

if [ ! $1 ]; then
	echo 'Usage: watchfolder CMD'
	echo '	Everytime some files or folders change under $PWD'
	echo '  the CMD command is executed'
	exit 1


WATCH=.; while E=`inotifywait -r -e modify,create $WATCH`; do echo $E; "$@"; echo -e 'done\n'; done

Can be made to execute `make` in current folder, or compile and/or execute a script or run tests when editing folder structure.

For Debian `apt-get install inotify-tools` is needed.