4

I'm trying to find all the web folders that are 777. But I only want a list of the top folders.

So if there is an img dir that has folders in it that are also 777 I don't want them returned.

Basically I'm looking for a way to have find stop descending after finding a folder that's 777.

find /var/www/vhosts/ -type d -perm 777

Gives me

/var/www/vhosts/example.com/httpdocs/img
/var/www/vhosts/example.com/httpdocs/img/gbl
/var/www/vhosts/example.com/httpdocs/img/ss

And all i want is the first one

/var/www/vhosts/example.com/httpdocs/img
Slashterix
  • 612
  • 1
  • 5
  • 19

1 Answers1

7

Use the -prune flag.

find /var/wwwhosts/ -type -d -perm 777 -prune should show exactly what you want.

Edit: Here's what this is doing for me, I believe this is what you wanted?

# ls -l
drwxrwxrwx 4 root root 4096 Feb 25 14:21 c

# ls -l c
drwxr-xr-x 2 root root 4096 Feb 25 14:21 1
drwxrwxrwx 2 root root 4096 Feb 25 14:21 2

# find . -perm 777 -prune
./c

# find . -perm 777 -prune -exec ls -ld {} \;
drwxrwxrwx 4 root root 4096 Feb 25 14:21 ./c
Christopher Karel
  • 6,582
  • 1
  • 28
  • 34