I want to find the permissions (777) for a directory recursively in a bash script. This is only finding directories permissions and not files. Any help appreciated.

```
#!/bin/bash
x=777
dir=/dir
perms=$(stat -c %a $dir)

if [[ $perms = $x ]]; then
find $dir -type d -perm $x  > list

fi

if [[ $perms = $x ]]; then
find $dir -type f -perm $x  >> list

fi

```