11
java -jar ~/Downloads/simian-2.3.35/bin/simian-2.3.35.jar files $(find ~/App/Classes/ -type f -name "*.m"  -not -path  "Lib/excludethisdir/*")

I'm trying to run simian and pass a file argument into it, but excluding a directory just isn't working. The Lib directory is contained in Classes

Can anyone point out why it's not working (The command runs, but it doesn't exclude)

imz -- Ivan Zakharyaschev
  • 4,921
  • 6
  • 53
  • 104
Killian
  • 936
  • 3
  • 14
  • 28
  • 1
    possible duplicate of [exclude directory from find . command](http://stackoverflow.com/questions/4210042/exclude-directory-from-find-command) – Reinstate Monica Please Aug 07 '14 at 18:03
  • Also not sure exactly what `simian` is, but this will fail on files that contain whitespace, and can run past `ARG_MAX` if `find` returns a lot of files. – Reinstate Monica Please Aug 07 '14 at 18:06
  • Hi BroSlow, simian is a copy paste detector written in Java. The files don't have whitespace. It doesn't seem to be hitting `ARG_MAX` as the command runs - 678 files. – Killian Aug 08 '14 at 08:25

1 Answers1

15

You nested find command should be:

find ~/App/Classes/ -type f -name "*.m"  -not -path "./Lib/excludethisdir/*"

i.e. add ./ before your excluded path.

Or even better:

find ~/App/Classes/ -path "./Lib/excludethisdir/*" -prune -o -type f -name "*.m" -print
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 2
    Worth noting that `-prune` is faster, i.e. something like `find ~/App/Classes/ -path "./Lib/excludethisdir" -prune -o -type f -name "*.m" -print` is faster than checking it each time. – Reinstate Monica Please Aug 07 '14 at 18:04
  • Thanks @BroSlow: I added it to my answer. – anubhava Aug 07 '14 at 18:09
  • Hi anubhava, this still doesn't work for me. Could it have something to do with where I am running the command from? I am in the "App" directory when I run this command, and "Lib" is a subdirectory of "Classes" – Killian Aug 08 '14 at 08:27
  • Yes you need to give full path to exclude.. So give `"./classes/Lib/excludethisdir/*` – anubhava Aug 08 '14 at 09:03