Ubuntu – Finding all directories with a certain string then changing permissions

findpermissions

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

Best Answer

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 Question