0

I have a directory with about 100 sub directories. Some of these sub directories are "Wordpress folders" others are not. What I would like to do is change the ownership of the themes and plugin directories inside the "Wordpress folders". I'm using this command to get the list of these directories:

find . -maxdepth 3 -type d | grep 'wp-content/themes\|wp-content/plugins'

How could I make change the ownership of all plugins and themes subdirectories?

pa4080
  • 30,621
koni_raid
  • 3,300

1 Answers1

2

You could modify your command in this way:

find . -maxdepth 3 -type d -regextype posix-extended -regex '.*wp-content/(themes|plugins)' -exec echo chown -R user:group {} +
  • Change the user:group pair with the actual user and group.
  • Change the end of the find command from {} + to {} \; to output separate commands for each directory - it could be more easy to read (reference).
  • Remove echo to do the changes.

I'm afraid that @muru's solution is more elegant :) It could be modified in this way:

echo chown -R user:group */wp-content/{themes,plugins}
  • Change the user:group pair with the actual user and group.
  • Remove echo to do the changes.
pa4080
  • 30,621