FreeKB - find command - exclude directories from search (-not -path)
Linux Commands - find command - exclude directories from search (-not -path)

If you are not familiar with the find command, check out our Getting Started article.

Let's say you want to search below /opt but you do not want to search /opt/tmp and /opt/user. The -not -path options can be used to exclude directories from the search. For example, the following command will exclude /opt/tmp and /opt/user from the search.

find /opt –not -path /opt/tmp/ –prune –not -path /opt/user/ –prune

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 51f8d in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |