28

I want to write a permission fix script that uses find to fix permissions on files.

Mainly what I need is a find command that is able to list all files with execute bit set, regardless of the other permissions on the file (that's the trick).

5
  • 2
    What have you already tried? What research have you done? As written right now, you're just asking us to do your work for you, and you haven't shown any effort whatsoever in solving this yourself.
    – EEAA
    Jul 21, 2013 at 14:30
  • Also, I'd highly recommend reading up on what types of questions are appropriate here before posting any more questions. You have quite a string of closed and down voted questions, and if not careful, you will likely run afoul of the automatic question ban.
    – EEAA
    Jul 21, 2013 at 14:40
  • @EEAA: Sadly, I doubt that's anywhere near close to happening. If you have any rep at all it's really hard to get q-banned.
    – user591
    Jul 21, 2013 at 14:46
  • @Iain - fair enough. Hopefully he'll still heed the advice, though.
    – EEAA
    Jul 21, 2013 at 14:47
  • 2
    @EEAA: I hope so too but people who can't be bothered to read manuals generally don't heed advice - they just find it easier to whinge about our attitude ... iyswim ;)
    – user591
    Jul 21, 2013 at 14:50

3 Answers 3

36

On GNU's find:

find /dir -type f -executable

On other versions, see the man page around -perm.

17

Believe it or not this is extensively documented in the find man page. On the CentOS and Ubuntu systems I have to hand there are even examples of this.

-perm /mode

Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify u',g' or `o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour of -perm -000).

So

find  . -perm /u+x

will find files where execute permission is set for the owner

find . -perm /u+x,o+x

will find files where execute permission is set for the owner and other and so on.

-1

Without using the find command, on zsh we can do something like this using Glob Qualifiers:

ls /path/to/some/parent/folder/**/*(*)

The above ls command will return all files in all subfolders of /path/to/some/parent/folder, which are executable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .