Find command to exclude a specific path

Hi Folks,

I want to run the below command and to exclude the specific path like /var/test/support/... . How to achieve using the below command

find / -type f \( �perm �4000 �o �perm �2000 \) �print

-Siva

You haven't told us what operating system or version of find you're using. With a standards-conforming find utility, you could use:

find / -type f \( -perm -4000 -o -perm -2000 \) | grep -v '^/var/test/support/'

If the man page for the find utility on your system includes a -path primary, you could try the following. If you find supports this primary, this version should be faster:

find / \( -type d -path '/var/test/support' -prune \) -o \( -type f \( -perm -4000 -o -perm -2000 \) \)'

You could add -print to the end of either one of the above find commands and not change the results.

1 Like

Hi Don,

I am using Redhat Linux and the command you have given has perfectly worked out for me..

Thanks.. :b: