我正在尝试搜索具有扩展属性(-ea)但在路径名中没有特定字符串的所有目录。我在尝试:
find / -ea -type d ! -name '*arcdst*'
然而,这仍然返回/ arcdst及其下的所有目录。我在这个站点上看过类似的答案,但是根据AIX手册页 - 不可用,也不是-path。这是AIX 6.1 TL6。
非常感谢, LarryD
答案 0 :(得分:0)
您的命令没有寻找没有arcdst的完整路径,但仅用于 名称不是 arcdst 的目录。 我希望找到目录arcdst下的目录和文件, 但是find应该跳过结果中的顶层目录。
如果你不介意一点开销,你可以过滤结果。
find / -ea -type d | grep -v 'arcdst'
当你不希望找到首先查看arcdst时,你可以告诉它不要查看arcdst目录
find $(ls / | grep -v arcdst) -ea -type d
答案 1 :(得分:0)
您应使用-name
选项代替! -path "pattern"
:
find / -ea -type d ! -path "*arcdst*"
这将跳过"*arcdst*"
路径
或者您可以使用-regex
选项:
find / -ea -type d ! -regex ".*arcdst.*"