chmod files only in all subdirectories
Please someone assist me with chmod, I have the following file structure
-dir1
--file1
--file2
--dir1a
---file1a1
---file1a2
--dir1b
---file1b1
---file1b2
How do I chmod 655 to all files under dir1 and all subdir? So all files will have 655 permission and all dir will remain as they were.
Thank you
Solution 1:
Better to use
find . -type f -exec chmod 655 -- {} +
The other proposed solution from @sagarchalise will not work if filenames contain spaces or start with a dash.
Solution 2:
I think going inside dir1
and
find . -type f | xargs chmod 655
will do the trick.
Or this version, which supports file names with spaces:
find . -type f -print0 | xargs -0 chmod 655