Skip to content

Instantly share code, notes, and snippets.

@krisahil
Created March 18, 2014 14:24
Show Gist options
  • Save krisahil/9621094 to your computer and use it in GitHub Desktop.
Save krisahil/9621094 to your computer and use it in GitHub Desktop.
List info about all contrib modules available on a Drupal site.
#!/bin/bash
tmp="/tmp/temp-file"
alias=""
# List all contrib modules.
for name in $(drush $alias sql-query "SELECT name FROM system WHERE type = 'module' AND filename LIKE 'sites/all/modules%'"); do
# Skip header row.
if [[ "name" == $name ]]; then
continue
fi
drush $alias pmi $name > $tmp
# Parse the output for each facet, and use sed to trim whitespace.
version=$(grep '^ Version' $tmp | cut -d \: -f2 | sed 's/ *$//' | sed 's/^ *//')
title=$(grep '^ Title' $tmp | cut -d \: -f2 | sed 's/ *$//' | sed 's/^ *//')
desc=$(grep '^ Description' $tmp | cut -d \: -f2 | sed 's/ *$//' | sed 's/^ *//')
project=$(grep '^ Project' $tmp | cut -d \: -f2 | sed 's/ *$//' | sed 's/^ *//')
# Format into human readable.
echo "$title (http://www.drupal.org/project/$project, $version): $desc"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment