James Mclaren
James Mclaren

Reputation: 674

Find command ignore directory

I am trying to find all files ending in .jar, but it is picking up folders that ends in .jar which is something I do not want.

My command so far

find . -name ".*jar"

I need it so it ignores directories ending in .jar

Additional request.

I now need to ignore a specific folder when looking, is this possible?

Thanks.

Upvotes: 0

Views: 1180

Answers (3)

Olaf Dietsche
Olaf Dietsche

Reputation: 74018

Others have already shown, how to pick up files named ending in .jar. As an answer to your comment "How to ignore a specific folder". You use -prune for that

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

Upvotes: 2

lukuluku
lukuluku

Reputation: 4404

that's what you want

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

see man page:

-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

Upvotes: 0

pbhd
pbhd

Reputation: 4467

just add -type f:

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

Upvotes: 3

Related Questions