执行inotifywait来监视目录,并试图排除所有子目录,同时不排除文件。
inotifywait -r -q --exclude <pattern> dir/在<pattern>里放什么?inotifywait手册指定:
--exclude <pattern>
Do not process any events whose filename matches the specified POSIX extended regular expression, case sensitive.在-type中没有像find那样的标志。我尝试过(^/),但这似乎排除了一切。
帮助感激。
发布于 2014-11-03 19:50:36
因为--exclude选项只对文件名起作用,所以没有直接的方法。您可以尝试使用find打印所有目录的名称这样的周全方式:
inotifywait --exclude "echo -n (;$(find . -maxdepth 1 -mindepth 1 -type d -printf '%P|');echo )" .注意,我没有指定-r,因为这也会导致新创建的子目录被监视。
这可能会打破一些特殊的字符。
你也可以尝试:
find . -maxdepth 1 -mindepth 1 -type d -printf '@%P\n' > list_of_directories
inotifywait --fromfile list_of_directories .inotifywait将排除以@开头的list_of_directories中的任何文件或文件夹(所有这些文件或文件夹都会)。
如果您使用的是inotifywait和递归选项,那么通过删除-maxdepth限制(也适用于第一个命令),让find列出所有嵌套的子目录:
find . -mindepth 1 -type d -printf '@%P\n' > list_of_directories
inotifywait --fromfile list_of_directories . -r保留-mindepth以防止find匹配.,从而也排除当前目录。
发布于 2015-07-11 02:51:58
只需使用--exclude '/\..+'。这将忽略以点开始的所有文件。
( .+部件使其不排除基本文件夹)。
发布于 2014-11-02 17:54:28
inotifywait只检查子目录,因为参数-r。
在没有该参数的情况下调用它,它将不会监视子目录。
https://askubuntu.com/questions/544733
复制相似问题