查找文件但排除几个目录?

sup*_*ted 5 linux bash shell ubuntu bash-scripting

如何find列出每个文件但从搜索中排除少数目录?

find / -type f -not -path "./foo*" -not -path "/bar*" -print
Run Code Online (Sandbox Code Playgroud)

我在其他 stackexchanges 上看到过示例,例如./,但我尝试过的似乎都不起作用。

这有点有效:

find / -type f -not -path "*foo*" -not -path "*bar*" -print
Run Code Online (Sandbox Code Playgroud)

但事实并非如此;它还从搜索结果中排除名为“foo”和“bar”的文件。

pim*_*pim 3

find / -type f -not -path "*foo*/*" -not -path "*bar*/*" -print似乎可以解决问题。