Reputation: 13
I currently use the following two commands:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
I am under the impression that one changes all directories and subdirectories to 755 and the other changes all files and files in subfolders to 644
I would like to pick and choose the subdirectories.
For example:
find . -type d -exec chmod 755 {/sudirectoryOfCurrentDirectory} \;
How do I pick a subdirectory and subdirectories in that subdirectory? How do I pick a subdirectory and all files in that subdirectory and it's subdirectories?
Upvotes: 1
Views: 1439
Reputation: 1627
I'm not sure if I understand you correctly but when I look other answers they looks so complex according to your need.
You requested, you want to change given directory's subdirectories ? Isn't it ?
It basically means.
find ./yoursubdirectory -type d -exec chmod 755 {} \;
Upvotes: 1
Reputation: 2789
You can do the following:
To pick a subdirectory, and all directories in that subdirectory, recursively:
chmod <permission> `find path/to/subdirectory -type d`
To pick a subdirectory, and all files in that subdirectory, recursively:
chmod <permission> `find path/to/subdirectory -type f`
Example:
chmod 755 `find name_of_subdir -type d` # all directories in subdir
chmod 755 `find name_of_subdir -type f` # all files in subdir
Upvotes: 0
Reputation: 3766
The following would list every directory and ask if you want to chmod 755
it. Answer y
to chmod it.
find . -type d | xargs -p -n 1 chmod 755
You could use grep to include patterns:
find . -type d | grep subdirectoryOfCurrentDirectory | xargs chmod 755
Or you could use grep to exclude patterns:
find . -type d | grep -v subdirectoryOfCurrentDirectory | xargs chmod 755
Upvotes: 1