There can be cases where you are searching for a file but you want to exclude some particular directories from the search.
-prune is used to ignore files and directories from your search
Lets see some examples
Exclude "work" directory in your search to find "myfile" document.
The below command will lookout for all the files with name "myfile" inside /root/
# find /root/ -name myfile -type f
/root/deepak/myfile
/root/work/myfile
To exclude "work" directory
# find /root/ -path '/root/work' -prune -o -name myfile -type f -print
/root/deepak/myfile
# find /root/ -name 'work' -prune -o -name myfile -type f -print
/root/deepak/myfile
Excluding multiple directories from your search
Exclude any directory with name work and home
# find . ( -name work -o -name home ) -prune -o -name myfile -type f -print
To learn more about find command follow the below link
10 Practical Examples for using FIND Command in Linux
Related Articles
10 practical examples to use USERADD command in linux
Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
Tutorial for SYSLOG with Examples in Red Hat Linux
9 examples to help you understand top command usage in Unix/Linux