Operating System - Linux
1832210 Members
2764 Online
110040 Solutions
New Discussion

Using "FIND" to locate files with modes greater than 644

 
john guardian
Super Advisor

Using "FIND" to locate files with modes greater than 644

What's a good form of the find cmd that can be used to find all files with perms > 644?

Anyone?
6 REPLIES 6
Sandman!
Honored Contributor

Re: Using "FIND" to locate files with modes greater than 644

What do you mean by > 644? Could you clarify what you are trying to get at?

~thanks
Court Campbell
Honored Contributor

Re: Using "FIND" to locate files with modes greater than 644

I believe that he is looking for files that are

744
754
764

and so on. But I am with you, what defines greater than 644? Could 477 possibly be greater than 644?
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
James R. Ferguson
Acclaimed Contributor

Re: Using "FIND" to locate files with modes greater than 644

Hi John:

If by "greater than 644" you mean numerically greater, as for example "650" then something linke this (using Perl) :

# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && ((stat(_))[2] & 07777) >= 0644},@ARGV)' /dir

...substitute whatever you need for the "/dir" path.

Regards!

...JRF...
john guardian
Super Advisor

Re: Using "FIND" to locate files with modes greater than 644

Sure, no problem.

I need to create a list of all files with a mode greater than what you see below

-rw-r--r-- (644)

For example:

-rwx-r--r-- (744) or
-rw-rw-r-- (664) or
-rw-rw-rw- (666) and so on.

In other words, the list needs to include all files with the following permissions and/or characteristics:

owner execute, group write/execute and world write/execute.

So, the following (x'd) mode bits are disallowed:

---x-xx-xx

Thanks.

john guardian
Super Advisor

Re: Using "FIND" to locate files with modes greater than 644

Perl works great... which is what I'd normally use, but some of the machines that these scripts will run on can only be expected to have a bourne shell. Sorry, I should have been more specific.

Also, yes... 477 is greater than 644 in that the "permissions" or (some) of the digits are greater ... while the combined absolute value of all of the digits might not necessarily be so. Once again, I should have been more specific.

Sorry.
James R. Ferguson
Acclaimed Contributor

Re: Using "FIND" to locate files with modes greater than 644

Hi (again) John:

No Perl? Boo. OK, then try a long-hand approach using 'find' and something like:

# find /path -type f -perm -u+s -o -perm -u+w

...etc.

Regards!

...JRF...