1

How to exclude a folder or path from a command or application in general?

I am trying to exclude a path from find command but available possibilities like prune option explained here and here makes the command a little more complicated to achieve advanced search

intika
  • 14,406

1 Answers1

1

For any command or application

Linux namespace can be used easily with firejail like the following example

firejail --noprofile --quiet --blacklist=/path/to/exclude command-or-app

Alternative way to exclude directory from find

firejail --noprofile --quiet --blacklist=/path/to/exclude find /search/location -name am-looking-for-this

Note that this method will deny access to /path/to/exclude, find command will print stderr with access denied and exit status will not be 0. 2>/dev/null can be used at the end of the command to hide stderr if needed, but keep in mind that this can hide other important errors as well. Other additional implementation like this or this may be used as well.

Find command:

Options available within find command are explained here, here and the following example:

find . -path ./exclude/this -prune -o -print
intika
  • 14,406