How can I exclude PATTERN from inotify/incron
I'm using incron to watch for events in a directory but I want to exclude some subdirectory 开发者_开发知识库or some filename PATTERNS.
Is there a way I can do this elegantly?
Incron doesn't support pattern filters, so you'll need to implement your own.
A simple example for just one file extension could be:
Incrontab:
/watched/directory IN_ALL_EVENTS /usr/local/bin/incronfilter .pyc $# /bin/echo $@/$# $& $%
incronfilter:
#!/bin/bash
ext=$1
file=$2
shift 2
[ "$file" == "${file%$ext}" ] && $*
Hope it helps.
精彩评论