Search code examples
linuxfindgnu

find tries to access unreadable directory even though it is explicitly excluded


This command: find $HOME/Dev/missing \( -not -path '/home/filip/Dev/missing/.password-store' \)

returns this:

/home/filip/Dev/missing
find: ‘/home/filip/Dev/missing/.password-store’: Permission denied
/home/filip/Dev/missing/data-wrangling

But I excluded the path that can't be read.

Is there a way to disable this behavior?


Solution

  • While you are excluding the exact path .password-store itself, find is still looking to descend into it (assuming it is a directory). The -prune option stops snips off the search tree at this point and stops any further exploration within this path.

    Try something like:

    find $HOME/Dev/missing -path $HOME/Dev/missing/.password-store -prune -o -print