user13402843
user13402843

Reputation: 25

chmod recursive, but exclude starting directory

From what I can tell, I've run into a limitation of chmod - hoping to pick the more experienced brains here before resorting to writing some find scripts.

I would like to chmod -R all files & directories within a folder, but leave the folder itself alone. I need to avoid the permissions of the starting directory changing, at all during this process, so a simple chmod -R followed by a non recursive chmod to reset the permissions on the starting directory isn't an option.

Any ideas?

Upvotes: 2

Views: 1177

Answers (1)

that other guy
that other guy

Reputation: 123490

Simply give chmod all the files and subdirectories inside the directory, rather than the directory itself. This is easily done with a glob pattern:

chmod -R dir/*

If you want to account for hidden files and dirs, you can shopt -s dotglob in bash.

Upvotes: 3

Related Questions