Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to monitor special path to any event of create or modified files recursively in it via inotifywait but I don't know what's my problem is.

I have some folders that I want to exclude.

    ->  folder1
        -> file1
        -> ingnorefile1 [IGNORE]
    ->  ignorefolder1 [IGNORE]

How do I correctly exclude them using a regular expression?

inotifywait -mr --exclude '(ignorefolder1|folder1\/ingnorefile1)' -e modify -e create -e delete . | while read date time dir file; do

What is correct regular expression to use to accomplish my goal?

share|improve this question

Correct regexp: (ignorefolder1|folder1/ingnorefile1). But your expression works too.

Using a backslash to escape a non-metacharacter is an error. "/" is not a metacharacter and does not need to be escaped.

share|improve this answer
when i create some files in ignorefolder1 event send. – sweb Jul 1 '12 at 19:22
when i create some files in ignorefolder1 event not send. i run inotifywait -mr --exclude '(ignorefolder1|folder1/ingnorefile1)' -e modify -e create -e delete . and echo foo > ignorefolder1/bar – jnizjo Jul 1 '12 at 23:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.