LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 03-01-2009, 04:32 AM   #1
manojrsb
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
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?
 
Old 03-01-2009, 07:34 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
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.
 
Old 03-02-2009, 01:50 AM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 663

Rep: Reputation: 132Reputation: 132
Quote:
Originally Posted by manojrsb View Post
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
 
  


Reply

Tags
scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify Perl script to work with txt - Permissions script joangopan Programming 4 09-14-2007 09:20 PM
file permissions find ygloo Programming 4 10-09-2006 01:25 PM
Identical disks that are not identical staphanes Linux - Hardware 8 03-11-2006 11:50 AM
APACHE Problem 2 dirs, identical permissions and security contexts, one gives 403? tones Linux - Software 2 03-13-2005 08:45 AM
how to find the pid of a perl script from shell script toovato Linux - General 1 12-19-2003 06:25 PM


All times are GMT -5. The time now is 12:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration