Execute drush command against against multiple groups We have a large set of Drupal instances, and we use Drush alias groups to group them logically. For example, we have a group "dev" for all sites "in development", and, for example, another called "7_36" for all on Drupal core 7.36.

I can currently run commands against all sites in a single group (drush @dev status), but is it possible to run a command against all sites which are in both groups? For example, I'd like to run a command against all sites found both in @dev and in @7_36.

Is this possible?
You can create a new alias group that is the combination of the two (by hand):

$aliases['newCombinedGroup'] = array(
  'site-list' =&gt; array(
    // Dev group 1 sites
    'site1', 
    'site2',
    'site3',
    // 7_36 group 2 sites
    'site6', 
    'site7',
    'site8',
  ),
);


This is discussed in this other thread:
How to use Drush&#39;s concurrent execution capability?

Another option as pointed out by the maintainer of Drush here:
https://drupal.stackexchange.com/a/134472/3279

is to compose your alias group site names for example from a PHP array of site names, then build your alias entries programmatically by looping through these site  names and filling out the contents of the drush alias itself.

So something like:

// This is untested example code.
$sites_in_dev = array('site-dev-1', 'site-dev-2');
$sites_in_736 = array('site-1', 'site-2');

$aliases['newCombinedGroup'] = array(
  'site-list' =&gt; $sites_in_dev + $sites_in_736;
);
$aliases['@dev'] = array('site-list' =&gt; $sites_in_dev);
$aliases['@7_36'] = array('site-list' =&gt; $sites_in_736);

foreach ($sites_in_dev as $sitename) {
  if ($sitename == 'site-dev-1') {
    $aliases['Dev1'] = array( /* ... */ );
  }
  if ($sitename == 'site-dev-1') {
    $aliases['Dev2'] = array( /* ... */ );
  }
}

foreach ($sites_in_736 as $site) {
  // ... etc ...
}


.... You get the idea. Also I would refrain from using @7_36 as an alias name. In general PHP variables shouldn't start with numbers -- and while an alias isn't a php variable persay you're playing with fire by giving it a name that would be an invalid php variable name; when evaluated now and in future versions of Drush ... who knows how that will behave.