Linux chmod:如何仅向已具有执行权限的文件递归添加执行权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6937885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
chmod: How to recursively add execute permissions only to files which already have execute permission
提问by Clinton
I noticed:
我注意到:
chmod -R a+x
adds execute permissions to all files, not just those who are currently executable.
chmod -R a+x
为所有文件添加执行权限,而不仅仅是那些当前可执行的文件。
Is there a way to add execute permissions only to those files who already have an execute set for the user permission?
有没有办法只向那些已经为用户权限设置执行集的文件添加执行权限?
采纳答案by Oliver Charlesworth
Use find
:
使用find
:
find . -perm /u+x -execdir chmod a+x {} \;
回答by Reto Aebersold
You can use find to get all those files:
您可以使用 find 来获取所有这些文件:
find . -type f -perm -o+rx -print0 | xargs -0 chmod a+x
Update: add -print0 to preserve space in filenames
更新:添加 -print0 以保留文件名中的空间