I have a lot of files in one specific folder, and I want to change the permissions only for files and only in this folder (not subfolders), how can I achieve this? Thanks in advance.
Asked
Active
Viewed 2,918 times
1 Answers
6
find your_folder -type f -exec chmod your_permissions {} \;
This command changes the permissions only for regular files in the selected folder (replace "your_folder" and "your_permissions" with the appropriate values).
If you only want to change the permissions for files in your_folder itself and not in its subfolders you can add -maxdepth:
find your_folder -maxdepth 1 -type f -exec chmod your_permissions {} \;
{}
stands for whatfind
has found. – muclux May 24 '18 at 13:05{}
tells find to insert the find results into the formula, the\
in front of the semicolon is just an escape character. – Videonauth May 24 '18 at 13:06.
designates the current directory, not the files in it. – muclux May 24 '18 at 13:07*.*
is just calling for trouble this matches all and everything even the parent directory in some cases. – Videonauth May 24 '18 at 13:12