2013-02-20 92 views
0

我正在尝试查找以.jar结尾的所有文件,但它正在拾取以.jar结尾的文件夹,这是我不想要的。查找命令忽略目录

我的命令到目前为止

find . -name ".*jar" 

我需要它,所以它会忽略的.jar

额外的请求结束目录。

我现在需要在查找时忽略特定的文件夹,这可能吗?

谢谢。

回答

3

只需添加型的F:

find . -name "*.jar" -type f 
+0

此外,它应该可能是'“* .jar”'而不是'“。* jar”'。 – 2013-02-20 13:54:03

+0

只是改变了它... – pbhd 2013-02-20 13:55:05

+0

这工作得很好。还有一个额外的请求。如何在搜索时忽略特定的文件夹? – 2013-02-20 13:55:21

0

这就是你想要什么

find . -type f -name "*.jar" 

见手册页:

-type Type 
    Evaluates to the value True if the Type variable specifies one of the following values: 
     b 
      Block special file 
     c 
      Character special file 
     d 
      Directory 
     f 
      Plain file 
     l 
      Symbolic link 
     p 
      FIFO (a named pipe) 
     s 
      Socket 
2

其他人已经表示,如何拿起文件命名结束于.jar。作为对“如何忽略特定文件夹”的评论的回答。您使用-prune那个

find . -name 'specific/folder' -type d -prune -o -type f -name '*.jar'