I\'m trying to run a find
command for all JavaScript files, but how do I exclude a specific directory?
Here is the find
code we\'re using.<
I was using find
to provide a list of files for xgettext
, and wanted to omit a specific directory and its contents. I tried many permutations of -path
combined with -prune
but was unable to fully exclude the directory which I wanted gone.
Although I was able to ignore the contents of the directory which I wanted ignored, find
then returned the directory itself as one of the results, which caused xgettext
to crash as a result (doesn't accept directories; only files).
My solution was to simply use grep -v
to skip the directory that I didn't want in the results:
find /project/directory -iname '*.php' -or -iname '*.phtml' | grep -iv '/some/directory' | xargs xgettext
Whether or not there is an argument for find
that will work 100%, I cannot say for certain. Using grep
was a quick and easy solution after some headache.