[英]Find a folder by name and recursively set it's childrens folders permission to 755
Im trying to pipe the result of find . -type d -name 'uploads'
我正在尝试通过管道发送
find . -type d -name 'uploads'
的结果find . -type d -name 'uploads'
find . -type d -name 'uploads'
into another find function to then find all the child folders and set the permission, but it's not accepting it. find . -type d -name 'uploads'
到另一个查找函数中,然后查找所有子文件夹并设置许可权,但是它不接受它。
Can anyone help? 有人可以帮忙吗? What I want to do is find a folder called 'uploads', and all the child folders set their permissions to 755, and all the files to 777.
我想做的是找到一个名为“ uploads”的文件夹,所有子文件夹的权限都设置为755,所有文件都设置为777。
Not particularly elegant, but a while loop will do the job (unless you have folders with newlines in the name or something, in which case xargs
or parallel
would be a better choice) 并不是特别优雅,但是可以使用while循环来完成工作(除非您的文件夹名称或名称中包含换行符,否则
xargs
或parallel
会是一个更好的选择)
find . -type d -name 'uploads' | while read d; do chmod -R 755 "$d"; done
... with xargs, you can only do the single command, but that seems to be all you need ...使用xargs,您只能执行单个命令,但这似乎就是您所需要的
find . -type d -name 'uploads' -print0 | xargs -0 chmod -R 755
E: To follow the request to make all the sub-directories 755 and files 777, the while loop will do it: E:按照请求创建所有子目录755和文件777,while循环可以做到:
find . -type d -name 'uploads' | while read d; do
find "$d/" -type d -print0 | xargs -0 chmod 755;
find "$d/" -type f -print0 | xargs -0 chmod 777; done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.