We are frequently perform different operations on file systems. One of the common operations is file searching. The task is so simple but it consuming more time when our system has a large number of files. However, we can make it easy by excluding some directories from the search path.
In this post we will discuss about different ways to achieve this with the find command.
Using the -not Operator:
We are able to exclude a directory from a search path using -not operator:
$ find . -type f -not -path '*/mp4/*'
The above code exclude the mp4 directory from our search path.
Using the ! Operator
Another way to exclude a directory is to use the ! operator with the find command:
$ find . -type f ! -path '*/txt/*'
The above code exclude the text files directory from our search path.