find . \( -type f  \) -o \( -name "*.rpm"   -prune \)

find . \( -name "*.sh" \) -o \( -name "*.rpm"  -prune \)

The second command excludes .rpm but the first one doesn't. What's the problem with first one?
Os:: Rhel 6(Redhat Enterprise Linux 6)

  • There is no problem with the first one. It just prints out a list of files, the -o part is never executed unless you have directories or links ending in .rpm.
    – Anthon
    Oct 10, 2015 at 11:46
  • ! Just negates the .rpm that's fine but is there any alternative for -o so that the -prune also gets executed
    – AVS
    Oct 10, 2015 at 12:05
  • I only use pruning in find on directories, so you don't recurse in the branches (= subdirectories) underneath. WIth find anding is implicit, -o has to be given explicitly.
    – Anthon
    Oct 10, 2015 at 13:07

1 Answer 1


Your first command matches all files it never comes to pruning .rpm files. Try:

find .  -type f  ! -name "*.rpm" 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .