PROJECTS
|___ SITE1
| |____files (to exclude)
| |____img
| |____js
|
|___ SITE2
| |____files (to exclude)
| |____img
| |____js
|
|___ SITE3
|____files (to exclude)
|____img
|____js
Hello, I’d like to search into SITEx folders excluding content of files folders.
I try this but it display me permissions errors for files into files folders (so seem to not exclude them) :
find . ! -path "*/files/*" -type f -name 'foo'
It display (I’m in PROJECTS directory):
./SITE1/img/foo.png
./SITE1/js/foo.js
find: `./SITE1/files/201501': Permission denied
find: `./SITE1/files/201412': Permission denied
find: `./SITE1/files/201501': Permission denied
... (the two firsts matches are pretty good, but I break the execution after, it print too many indesirble matches)
I was inspired by this response on askubuntu.
I also try the -prune option like in this example without finding a solution…
I’d like to have the equivalent of this search with egrep but for filenames
egrep -Rns --exclude-dir=files 'foo' *
Thanks for your help !
find
on Linux or are you able to use Windows for this?-prune
directive offind
. I suggest that you search for examples (there are a few good ones right here at Super User), because the man page by itself is not very illuminating on the subject of how to use-prune
.-"files" -directory
and it does exactly what is asked without having to first open a new terminal window,cd
'ing to the directory, then figuring out the syntax of thefind
command. The*nix
seems a lot like the "long" way. But I'm not here to evangelise, I was just wanting to see if other options were available or if another method would help.