Performing actions on all your WordPress installations


With this simple shell script, you can perform actions on all of your WordPress installations at the same time. This particular example changes the file ownership, but you can easily modify it to run the commands you need. It is based on my previous post about searching for WordPress installations.


for wp_config_file in $(find /var/www/ -type f -name 'wp-config.php' -print0 | tr '\0' '\040')
        this_wp_directory=$(echo "$wp_config_file" | replace '/wp-config.php' '')
        chown -R root:root $this_wp_directory
        chown -R www-data:www-data $this_wp_directory/wp-content/uploads
        echo "Fixed file permissions on $this_wp_directory"