Currently I have to disable all of the ubercart modules in bulk, but there are too many of them to do it one at a time via the modules page. And doing it via drush doesn't disable every module related to ubercart sometimes. Is there a quick way to disable these modules via Drush in bulk matching a specific pattern?
1 Answer
Here's the drush recipe combined with a few other commands to disable modules in bulk:
drush pm-list | ack uc_ | ack Enabled | grep "\((.*)\)" | awk -F'(' '{print $2}' | awk -F')' '{print $1}' | xargs -i drush dis '{}' -y
Broken down:
drush pm-list
lists out all of your modulesack uc_
returns only the lines matching "uc_"ack Enabled
returns only the enabled modulesgrep "\((.*)\)"
matches the words in parenthesesawk -F'(' '{print $2}'
breaks up the line starting with the(
characterawk -F')' '{print $1}'
breaks up the line starting with the)
characterxargs -i drush dis '{}' -y
runs the returned result into drush disable command with the-y
parameter for yes to all.
Thanks to greg_1_anderson, I updated it to be a bit shorter.
drush pm-list --status=enabled --pipe | grep 'uc_' | xargs -i drush pm-disable '{}' -y
-
This is cool, but could probably be simplified somewhat using
drush pm-list --pipe | grep uc_
. May 31, 2013 at 20:17 -
im sure it can be simplified, its just that im using what i know so far.. kinda long and barbaric i must say. May 31, 2013 at 20:19
-
drush pm-list --status=enabled --pipe
will return only the enabled modules. Sorry, didn't notice you were awk'ing out the disabled modules. Also, you can drop the awk, since pm-list is outputting one module name per line and nothing more. May 31, 2013 at 22:39 -
For clarity/readability and making it easier to replace the pattern for non shell experts, perhaps doing it like
PATTERN='uc_'; drush pm-list --status=enabled --pipe | grep ${PATTERN} | xargs -i drush pm-disable '{}' -y
would be even better, if a bit more verbose. Jun 1, 2013 at 14:15 -
I found I had to remove the xargs -i argument. I think it maybe should be -I (capitalised), but also --pipe returns string rather than separate lines, so that can happily be fed straight into drush pm-* Oct 15, 2014 at 10:37