Ignorieren Sie neue Verzeichnisse, wenn Sie mit inotifywait nach neuen Dateien suchen

1008
David Custer

Ich verwende inotifywait, um nach neuen Dateien zu suchen. Ich möchte jedoch neue Verzeichnisse ignorieren. Ich kann anscheinend nichts zur Arbeit bekommen.

Folgendes verwende ich:

#!/bin/sh MONITORDIR1="/hdd_1/path/to/dir" MONITORDIR2="/hdd_1/path/to/dir" #MONITORDIR3="/hdd_1/path/to/dir" #MONITORDIR4="/hdd_1/path/to/dir"  monitor() { inotifywait -m -r -e create --exclude '/\..+' --format "%f" "$1" | while read NEWFILE do echo "This is an automated email." | mail -s "$ has been added to Daemon!" "user@domain.com" done } monitor "$MONITORDIR1" & monitor "$MONITORDIR2" & #monitor "$MONITORDIR3" & #monitor "$MONITORDIR4" & 
2

1 Antwort auf die Frage

0
temoto

Das ist einfach. Entfernen Sie das Recurse-Flag -rund listen Sie vorhandene Verzeichnisse mit auf find.

monitor() { dirs=$(find "$1" -type d) inotifywait -m -e create --exclude... --format... $dirs |while ... }