0

I want to write a shell script that finds files in a directory that are (owner permissions) readable, writeable, or executable for the owner. But I don't know the command to list files with certain permissions (rwx)... I'm sure it has something to do with ls, but I just can't figure it out. Please help.

4
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by dilkash2007
0

find /path/to/search -type f -perm XXX

Where XXX = 775 for example.

read = 1
write = 2
execute = 4

each section, user, group, and world (or other) has these 3 attributes.

0

Thank you. I dsovered that
ls -l | grep "^-r........" (and so on with w, x) does finds the files.

0

Hey There,

This should get you files that are readable, writable or executable by the user/owner and will keep you from missing directories and such with the grep command:

find /your/base/dir -perm -u+r,u+w,u+x

This way if any combination, or all, of the permissions are set for the user/owner your match will come up positive.

Hope that helps :)

, Mike

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.