Much ado about scripting, Linux & Eclipse: card subject to change


Pattern Match Searches Within Multiple Files And Archives

Have you ever wondered what plugin is locking a particular file extension, and forcing it to be opened with a certain editor? Or wanted to scan some plugins to check their copyright information? Whatever the filetype, this script will allow you to search inside zips and jars for text files matching a given regular expression. Sure, there's probably a graphical way to do this, but nothing beats the purity of the almighty commanline.

Here's some sample output, looking for the plugins that lock *.mod files:

$ ~/eclipse/eclipse-plugins-other "*.jar" "plugin.xml" "extensions.*.mod" -verbose

** [1] /tmp/plugins/org.eclipse.wst.dtd.core_1.1.200.v200710021541.jar!plugin.xml **
41-     <extension point="org.eclipse.core.runtime.contentTypes">
42-             <content-type
43:                     file-extensions="dtd,mod,ent"
44-                     priority="normal"
45-                     name=""

** [2] /tmp/plugins/org.eclipse.wst.xml.ui_1.0.400.v200711071909.jar!plugin.xml **
16-     <extension point="org.eclipse.wst.xml.ui.catalogFileType">
17-             <fileType
18:                     extensions="dtd, ent, mod"
19-                     description="%_UI_PREF_DTD_FILES"
20-                     id="org.eclipse.wst.xml.core.ui.catalogFileType.dtd">

Looking for files that aren't in zips? Use this simpler script:

$ ~/eclipse/eclipse-plugins-enable34/ "feature.xml" "2007 by" -verbose

** [1] /tmp/features/org.eclipse.eclipsemonkey_1.0.0.200706060947/feature.xml **
12-   <copyright>
13:      Portions copyright 2007 by Aptana Inc.
14:Other portions copyright 2006-2007 by Eclipse Foundation Inc.
15-   </copyright>

Oh, and if you don't see red when you run these, make sure you have this in your ~/.bashrc, /etc/bashrc, or /etc/bash.bashrc file:

export GREP_OPTIONS='--color=auto'