Finding all directories with a certain string then changing permissions
5,393
I would use the find
command:
find . -type d -name 'domain-*' -exec chmod 755 {} +
.
specifies the path to search.-type d
makes this only apply to directories.-name ...
specifies the name of the directories this should apply to.-exec ... {} +
is the command that will be run for each collection of matchs.
Related videos on Youtube
Author by
kelly johnson
Updated on September 18, 2022Comments
-
kelly johnson almost 2 years
I'm trying to combine two things.
I have to set permissions on a number of directories, all of which have "domain-" in their name.
I wanted to "find all directories in the current directory that have the string 'domain-' in their names and change the permissions to 755.
I keep getting syntax errors and am so frustrated that I just need to ask!
thanks
-
kelly johnson over 11 yearsThanks Thor, that was exactly what I needed and a nice explanation.