LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script to find whether permissions are identical?? (http://www.linuxquestions.org/questions/linux-newbie-8/script-to-find-whether-permissions-are-identical-708345/)

manojrsb 03-01-2009 05:32 AM

script to find whether permissions are identical??
 
hey folks...
m trying to write a script that tells us whether the permissions for two files,whose names will be given as arguments to the script, are identical.
And If the permissions for the two files are identical, i want to output the common permission field.or else, output each filename, followed by its permission field

have any ideas?? how can i approach?

David the H. 03-01-2009 08:34 AM

I hope this isn't a homework question.

I think you'll probably want to to get the output of "ls -l" for each file and put it in a variable name. Then use "cut" or parameter substitution to strip out the permissions fields from each variable string and use them as the test in an "if" statement. From that you can decide how to present the output information.

Valery Reznic 03-02-2009 02:50 AM

Quote:

Originally Posted by manojrsb (Post 3461197)
hey folks...
m trying to write a script that tells us whether the permissions for two files,whose names will be given as arguments to the script, are identical.
And If the permissions for the two files are identical, i want to output the common permission field.or else, output each filename, followed by its permission field

have any ideas?? how can i approach?

Code:

stat -c %a filename
or

Code:

stat -c %A filename


All times are GMT -5. The time now is 02:26 AM.