开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜