Member Avatar for cnet1989

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.

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.

Member Avatar for cnet1989

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

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

i'm new in unix,can someone help me study point of view

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.