search for duplicate modules within a site

Public

It's relatively easy to end up with duplicate modules within a site's file structure. In my experience, they can take a couple of forms. First, multiple versions of a module can be installed in different directories; for instance, one under the "profiles" directory and another under the "sites" directory. Another possibility is creating features to export settings and accidentally using a name already in use on the site.

When run from a site's docroot, the snippet below finds all module files, then strips off the paths, counts the unique occurrences of each name, and then returns all the results with more than one occurrence.

Get raw version
bash
  1. find . -name *.module | awk -F '/' '{print $NF}' | sort | uniq -c | sort -n | grep -vE "^\s.*1"