从find命令中排除文件

时间:2011-10-12 06:12:11

标签: find

如何排除find命令选择的最后一个文件?

[root@web1 shantanu]# find /home/wcuser/ -name "catalina.out"
/home/user/services/logs/catalina.out
/home/user/services/logs/catalina.out
/home/user/cash/logs/catalina.out

我想排除文件“/home/user/cash/logs/catalina.out”,因为它是非常旧的日志文件。

1 个答案:

答案 0 :(得分:1)

您可以通过以下命令之一执行此操作:

find /home/wcuser/ \( -name "catalina.out" ! -wholename "/home/user/cash/logs/catalina.out" \)


find /home/wcuser/ \( -name "catalina.out" -and ! -wholename "/home/user/cash/logs/catalina.out" \)