

- #Double commander debian repository linux beta update#
- #Double commander debian repository linux beta full#
not \( -path "some_dir/dir_to_exclude3" -prune \) not \( -path "some_dir/dir_to_exclude2" -prune \) \
#Double commander debian repository linux beta update#
# to update the beginning of your `-path` with that as well, like this:įind "some_dir" -name '*.js' -not \( -path "some_dir/dir_to_exclude" -prune \) # If you change your "starting point" path from `.` to something else, be sure # Exclude multiple paths and their contents, saving time by *not* recursing down # beginning with this match pattern but not otherwise in an excluded dir.įind. # "./dir_to_exclude_another_long_name", etc., as well as exclude all **files** # - This example pattern would exclude "./dir_to_exclude", "./dir_to_exclude1", # all examples below as well, if desired. # - You can add the asterisk to the end of the pattern to apply this pattern to Prune to save time by *not* recursing down the # in "./dir_to_exclude*", to exclude all files & folders beginning with the # Add the wildcard asterisk (`*`) to the end of the match pattern, as # Exclude one path, and its contents, saving time by *not* recursing down theįind. Remove the -name '*.js' part of each command below, of course, if you are looking for a generic answer and not trying to solve the OP's original question, which involved also finding only files with extension. The escaped parenthesis ( \( and \)) and the -prune option are very important. These are the best and most-effective patterns I have found, period. How do I exclude a specific directory when searching for *.js files using find? Quick summary and answer:įollow these patterns.


Printf " $name3_num $name3_perf\n\n"įind is incredibly important and powerful, but it is so nuanced and confusing! I set up a simple test of the three top upvoted answers on this question (replaced -print with -exec bash -c 'echo $0' \\\ But for specifying -prune to make sense, find needs to hit a directory and stop descending it, which clearly makes no sense with -depth or -delete on. Why doesn't it work with delete? For -delete to work, find needs to traverse the directory in DFS order, since -deletewill first delete the leaves, then the parents of the leaves, etc. prune works with any action except -delete. prune only works with -print and no other actions. To avoid printing the directory altogether, use a syntax that logically omits it.
#Double commander debian repository linux beta full#
If this sentence confuses you just make sure to use full paths through out the whole command like this: find /full/path/ -not \( -path /full/path/exclude/this -prune \). Important Note: the paths you type after -path must exactly match what find would print without the exclusion. I find the following easier to reason about than other proposed solutions: find build -not \( -path build/external -prune \) -name \*.jsįind build -not \( -path build/external -prune \) -not \( -path build/blog -prune \) -name \*.js
