14

I want to find all files/dirs that are not equal to .git*, so I tried the following commands, but it has the opposite effect (it prints the paths that contain .git).

$ find . ! -name "*.git"
$ find . ! -name ".*.git"
$ find . ! -name "*.git*"
$ find . ! -regex "*.git"
$ find . ! \( -name "*.git*" \)

I also tried the above commands with a \! escape, as in find . \! -name "*.git".

Q: What's the correct syntax for find "not equal to"?

tony19
  • 125,647
  • 18
  • 229
  • 307
  • 1
    @casperOne, Why is this question considered off-topic (and down-voted) while similar questions listed below are valid? * [How do I edit an existing tag message in git?](http://stackoverflow.com/questions/7813194/how-do-i-edit-an-existing-tag-message-in-git) * [Use pipe of commands as argument for diff](http://stackoverflow.com/questions/9847479/use-pipe-of-commands-as-argument-for-diff) * [Linux find command gotcha?](http://stackoverflow.com/questions/2591158/linux-find-command-gotcha) – tony19 Mar 24 '12 at 02:58

1 Answers1

17

Aha! I found it here:

$ find . ! -path "*.git*"
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
tony19
  • 125,647
  • 18
  • 229
  • 307