简体   繁体   English

按名称查找文件夹并将其子文件夹的权限递归设置为755

[英]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循环来完成工作(除非您的文件夹名称或名称中包含换行符,否则xargsparallel会是一个更好的选择)

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.

相关问题 递归查找,但具有特定的子文件夹名称 - find recursively, but with specific sub-folder name 我无法从“ script1.sh”运行“ script2.sh”(它们位于同一文件夹中并具有755权限) - I can't run 'script2.sh' from 'script1.sh' (they are in the same folder and have 755 permission) 如何递归设置权限,文件夹为700,文件为600,不使用查找 - How to set permissions recursively, 700 for folders and 600 for files, without using find 如何在现有文件夹树中(在每个现有文件夹中)递归创建文件夹? - How to create a folder recursively in an existing tree of folders (in each existing folder)? Linux:查找所有具有特定名称的文件夹,将其删除,然后将一个文件夹复制到这些文件夹的父目录中 - Linux: Find all folders with a particular name, remove them and have a folder copied into the parent directory of those folders laravel centOS 7 chmod 755/775 权限被拒绝“无法打开:无法打开流:权限被拒绝”,仅当我设置为 777 时才允许 - laravel centOS 7 chmod 755/775 permission denied"could not be opened: failed to open stream: Permission denied", only allows if I set to 777 在文件和文件夹的名称中递归填充0 - Recursively padding 0's in names of files and folders 递归查找具有相同名称的文件 - Recursively find files with same name 使用 UMASK 创建具有 755 权限的 unix 文件 - Creating unix file with permission 755 with UMASK 在文件夹中查找文件夹的命令 - Command to find a folder inside folders
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM