find -perm query | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

find -perm query

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-28-2006
napolayan napolayan is offline
Registered User
 
Join Date: Oct 2006
Last Activity: 8 April 2009, 2:10 PM EDT
Location: Bangalore, India
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
find -perm query

I was going through a find tutorial and just couldn't get it...can someone explain it like he/she would explain a brain damaged dodo?

"find allows you to specify a pattern that can be bit-wise ANDed with the permissions of the file. Simply put a minus sign before the octal value. The group write permission bit is octal 20, so the following negative value:

find . -perm -20 -print

will match the following common permissions:

+-------------------------+
|Permission Octal value |
+-------------------------+
|rwxrwxrwx 777 |
|rwxrwxr-x 775 |
|rw-rw-rw- 666 |
|rw-rw-r-- 664 |
|rw-rw---- 660 |
+-------------------------+
If you wanted to look for files that you can execute, (i.e. shell scripts or programs), you want to match the pattern "--x------," by typing:

find . -perm -100 -print

When the -perm argument has a minus sign, all of the permission bits are examined, including the set user ID bits. "


so the question is: what is the calculation behind the 20 in '-perm -20' and the 100 in '-perm -100'?

Regards,

Brain Damaged Dodo
Sponsored Links
    #2  
Old 11-28-2006
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 31 July 2014, 9:11 PM EDT
Location: Ashburn, Virginia
Posts: 9,899
Thanks: 59
Thanked 416 Times in 250 Posts
You have to know octal - binary conversion. 020 in octal is 000010000 in binary. And looking at the permission bits:
rwx rwx rwx
000 010 000

So we start with all zeros and replace the zero with a one if we are interested in that bit. Then we convert to octal. See my article on file permissions in our tips and tutorials section for more info.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find query duckeggs01 Shell Programming and Scripting 2 12-22-2011 06:34 AM
Help with find -perm option stevensw Shell Programming and Scripting 7 04-16-2011 01:01 PM
find and replace query lightdensity Shell Programming and Scripting 11 05-27-2009 07:15 AM
Wild card in find perm braindrain Shell Programming and Scripting 1 04-12-2007 06:24 PM
query about find and -exec shriashishpatil UNIX for Advanced & Expert Users 2 04-12-2007 01:16 AM



All times are GMT -4. The time now is 09:41 PM.