chmod: How to recursively add execute permissions

2019-03-12 16:04发布

I noticed:

chmod -R a+x adds execute permissions to all files, not just those who are currently executable.

Is there a way to add execute permissions only to those files who already have an execute set for the user permission?

2条回答
太酷不给撩
2楼-- · 2019-03-12 16:10

You can use find to get all those files:

find . -type f -perm -o+rx -print0 | xargs -0 chmod a+x

Update: add -print0 to preserve space in filenames

查看更多
forever°为你锁心
3楼-- · 2019-03-12 16:16

Use find:

find . -perm /u+x -execdir chmod a+x {} \;
查看更多
登录 后发表回答