I have a folder structure like this (which is a small snippet):
└── test
└── cases
└── model
├── client
│ ├── socketsTest.coffee
├── server
│ └── socketsTest.coffee
└── shared
└── findersTest.coffee
The question is, how do you list all paths that end in .coffee and don’t exist in the client folder?
The following command returns all files matching .coffee that exist in the server folder:
find test -name "*Test.coffee" | egrep '/*server*/'
But what I really need is a regex that matches everything except what’s in the client folder.
What is the cleanest way to do this on *nix? The end goal is to return files not inside a client folder, so for the above tree that would be:
$ <find files except those a client folder>
test/cases/model/server/socketsTest.coffee
test/cases/model/shared/findersTest.coffee
I tried doing something like this but no luck:
find test -name "*Test.coffee" | egrep '*model/[^client]*'
You can use the
-pruneaction to ignore directories.-omeans “or”, so read this as, “if it’s named client prune it, otherwise print files named*.coffee“.Or you can use a double test, which is easier to read but slightly less efficient, since it’ll recurse into
client/directories, whereas the first one avoids them entirely.