0
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 !
We need way more information. I have no idea what you are asking. You have no direct question. Try writing again so there is a specific question you are asking. – Eric F – 2015-01-13T17:08:33.393
1Unless I'm mistaken, which is possible, an exclusion causes the "hits" to be not displayed, but does not stop the directories from being looked into. The documentation (the --help output, the man page or something other) for the find command should indicate how find behaves. Did you look into this documentation? – killermist – 2015-01-13T17:18:07.113
This is actually disturbingly easy to do in Windows 8... are you stuck with
find
on Linux or are you able to use Windows for this? – Mokubai – 2015-01-13T18:11:38.370Try the
-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
. – G-Man Says 'Reinstate Monica' – 2015-01-13T18:44:42.320@Mokubai It's disturbing how much easier this is on
*nix
than onWindows 8
– None – 2015-01-17T09:38:25.2271@BroSlow On Windows 8 all you do is click inside the search box and type
-"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. – Mokubai – 2015-01-17T10:23:45.083@Mokubai That would be an ok option for this example, but it's still less precise (i.e. what if you have a file called
files
?). – None – 2015-01-17T18:31:37.097