LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Listing permissions with shell script (https://www.linuxquestions.org/questions/programming-9/listing-permissions-with-shell-script-244091/)

Ollir 10-18-2004 04:20 AM

Listing permissions with shell script
 
Hi,

I need to create a shell scipt, that lists the number of all files in a directory that the currently logged user has read permission, write permission and execute permissions. I'm trying to use the find-command with the -perm option, but is there a simple way to list all files with atleast read permissions etc? I mean not having to type tens of commands for ...-perm 400... -perm -444 and so on. Simple problem, but not for me ;)

theYinYeti 10-18-2004 06:50 AM

Number of files, in a directory /a/dir, for which current user has read, AND write, AND execute, permissions:
Code:

find /a/dir/ -perm -700 -print | wc -l
Number of files, in a directory /a/dir, for which current user has at least read permission:
Code:

find /a/dir/ -perm -400 -print | wc -l
Number of files, in a directory /a/dir, for which current user has read, OR write, OR execute, permissions:
Code:

find /a/dir/ -perm +700 -print | wc -l
Yves.


All times are GMT -5. The time now is 03:40 PM.